rtsp: unref sockets in _close
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 18 May 2012 07:20:54 +0000 (09:20 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 18 May 2012 07:47:26 +0000 (09:47 +0200)
When closing the connection, unref the currently used sockets. This should close
them when not in use. We need to do this because else we cannot reconnect
anymore after a close, the connect function requires that the sockets are NULL.

gst-libs/gst/rtsp/gstrtspconnection.c

index da9f510..22f3d0b 100644 (file)
@@ -2156,6 +2156,17 @@ gst_rtsp_connection_close (GstRTSPConnection * conn)
 {
   g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL);
 
+  /* last unref closes the connection we don't want to explicitly close here
+   * because these sockets might have been provided at construction */
+  if (conn->socket0) {
+    g_object_unref (conn->socket0);
+    conn->socket0 = NULL;
+  }
+  if (conn->socket1) {
+    g_object_unref (conn->socket1);
+    conn->socket1 = NULL;
+  }
+
   g_free (conn->ip);
   conn->ip = NULL;
 
@@ -2198,10 +2209,6 @@ gst_rtsp_connection_free (GstRTSPConnection * conn)
   g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL);
 
   res = gst_rtsp_connection_close (conn);
-  if (conn->socket0)
-    g_object_unref (conn->socket0);
-  if (conn->socket1)
-    g_object_unref (conn->socket1);
 
   if (conn->cancellable)
     g_object_unref (conn->cancellable);