From ad1dea3122b9dd08cc8bdc4fd115df88029dfd89 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 4 Feb 2009 11:18:31 +0100 Subject: [PATCH] Add more g_return_if_fail() calls Check that we have a valid file descriptor before entering certain functions in order to avoid undesirable situations. Add some more debugging in the connect method. --- gst-libs/gst/rtsp/gstrtspconnection.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c index 5d46e2c3e3..fbf2db09ef 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/gst-libs/gst/rtsp/gstrtspconnection.c @@ -300,7 +300,9 @@ done: sys_error: { + GST_ERROR ("system error %d (%s)", errno, g_strerror (errno)); if (conn->fd.fd >= 0) { + GST_DEBUG ("remove fd %d", conn->fd.fd); gst_poll_remove_fd (conn->fdset, &conn->fd); conn->fd.fd = -1; } @@ -310,15 +312,19 @@ sys_error: } not_resolved: { + GST_ERROR ("could not resolve %s", url->host); return GST_RTSP_ENET; } not_ip: { + GST_ERROR ("not an IP address"); return GST_RTSP_ENOTIP; } timeout: { + GST_ERROR ("timeout"); if (conn->fd.fd >= 0) { + GST_DEBUG ("remove fd %d", conn->fd.fd); gst_poll_remove_fd (conn->fdset, &conn->fd); conn->fd.fd = -1; } @@ -504,6 +510,7 @@ gst_rtsp_connection_write (GstRTSPConnection * conn, const guint8 * data, g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL); g_return_val_if_fail (data != NULL || size == 0, GST_RTSP_EINVAL); + g_return_val_if_fail (conn->fd.fd >= 0, GST_RTSP_EINVAL); gst_poll_set_controllable (conn->fdset, TRUE); gst_poll_fd_ctl_write (conn->fdset, &conn->fd, TRUE); @@ -906,6 +913,7 @@ gst_rtsp_connection_read_internal (GstRTSPConnection * conn, guint8 * data, g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL); g_return_val_if_fail (data != NULL, GST_RTSP_EINVAL); + g_return_val_if_fail (conn->fd.fd >= 0, GST_RTSP_EINVAL); if (size == 0) return GST_RTSP_OK; @@ -1290,6 +1298,7 @@ gst_rtsp_connection_poll (GstRTSPConnection * conn, GstRTSPEvent events, g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL); g_return_val_if_fail (events != 0, GST_RTSP_EINVAL); g_return_val_if_fail (revents != NULL, GST_RTSP_EINVAL); + g_return_val_if_fail (conn->fd.fd >= 0, GST_RTSP_EINVAL); gst_poll_set_controllable (conn->fdset, TRUE); @@ -1615,7 +1624,8 @@ wrong_family: * * Retrieve the IP address of the other end of @conn. * - * Returns: The IP address as a string. + * Returns: The IP address as a string. this value remains valid until the + * connection is closed. * * Since: 0.10.20 */