gst/tcp/: Be a bit more paranoid when freeing memory.
authorWim Taymans <wim.taymans@gmail.com>
Tue, 14 Sep 2004 14:03:16 +0000 (14:03 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 14 Sep 2004 14:03:16 +0000 (14:03 +0000)
Original commit message from CVS:
* gst/tcp/gstfdset.c: (gst_fdset_wait):
* gst/tcp/gstmultifdsink.c: (gst_multifdsink_close):
* gst/tcp/gsttcpserversink.c: (gst_tcpserversink_init_send),
(gst_tcpserversink_close):
Be a bit more paranoid when freeing memory.

ChangeLog
gst/tcp/gstfdset.c
gst/tcp/gstmultifdsink.c
gst/tcp/gsttcpserversink.c

index 1e54c3bdbd46ab21ca9ff75ae54352754924585b..c90d6d4aa13eb3959ea80a5fd9345030eebc36a4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-09-17  Wim Taymans  <wim@fluendo.com>
+
+       * gst/tcp/gstfdset.c: (gst_fdset_wait):
+       * gst/tcp/gstmultifdsink.c: (gst_multifdsink_close):
+       * gst/tcp/gsttcpserversink.c: (gst_tcpserversink_init_send),
+       (gst_tcpserversink_close):
+       Be a bit more paranoid when freeing memory.
+
 2004-09-13  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
 
        * gst/qtdemux/qtdemux.c: (gst_qtdemux_add_stream),
index b1a3f98a2880c075761879bd8dce58941c0951a7..f1f486eb152de5c0d5042f695263d8c29e787aca 100644 (file)
@@ -443,7 +443,7 @@ gst_fdset_wait (GstFDSet * set, int timeout)
     case GST_FDSET_MODE_SELECT:
     {
       struct timeval tv;
-      struct timeval *tvptr = NULL;
+      struct timeval *tvptr;
 
       set->testreadfds = set->readfds;
       set->testwritefds = set->writefds;
@@ -453,6 +453,8 @@ gst_fdset_wait (GstFDSet * set, int timeout)
         tv.tv_usec = timeout % 1000;
 
         tvptr = &tv;
+      } else {
+        tvptr = NULL;
       }
       res =
           select (FD_SETSIZE, &set->testreadfds, &set->testwritefds,
index e9a8611308d5a4efa99a3fede5114d17bbb36725..2ebc4463a3708a3c436d50bc73599b5ac57cd13e 100644 (file)
@@ -1435,26 +1435,28 @@ gst_multifdsink_close (GstMultiFdSink * this)
   this->running = FALSE;
 
   SEND_COMMAND (this, CONTROL_STOP);
-  g_thread_join (this->thread);
+  if (this->thread) {
+    g_thread_join (this->thread);
+    this->thread = NULL;
+  }
 
   close (READ_SOCKET (this).fd);
   close (WRITE_SOCKET (this).fd);
-  gst_fdset_remove_fd (this->fdset, &READ_SOCKET (this));
 
   if (this->streamheader) {
-    GSList *l;
-
-    for (l = this->streamheader; l; l = l->next) {
-      gst_buffer_unref (l->data);
-    }
+    g_slist_foreach (this->streamheader, (GFunc) gst_data_unref, NULL);
     g_slist_free (this->streamheader);
+    this->streamheader = NULL;
   }
 
   if (fclass->close)
     fclass->close (this);
 
-  gst_fdset_free (this->fdset);
-  this->fdset = NULL;
+  if (this->fdset) {
+    gst_fdset_remove_fd (this->fdset, &READ_SOCKET (this));
+    gst_fdset_free (this->fdset);
+    this->fdset = NULL;
+  }
 }
 
 static GstElementStateReturn
index d378631a3cf78c14861e525a38af833ffe7a05fd..ee4eab0b9f67e0602d659c60092139c3eaf6ef2d 100644 (file)
@@ -304,8 +304,6 @@ gst_tcpserversink_init_send (GstMultiFdSink * parent)
   gst_fdset_add_fd (parent->fdset, &this->server_sock);
   gst_fdset_fd_ctl_read (parent->fdset, &this->server_sock, TRUE);
 
-  //FD_SET (this->server_sock_fd, &parent->readfds);
-
   return TRUE;
 }
 
@@ -315,10 +313,10 @@ gst_tcpserversink_close (GstMultiFdSink * parent)
   GstTCPServerSink *this = GST_TCPSERVERSINK (parent);
 
   if (this->server_sock.fd != -1) {
+    gst_fdset_remove_fd (parent->fdset, &this->server_sock);
+
     close (this->server_sock.fd);
     this->server_sock.fd = -1;
-
-    gst_fdset_remove_fd (parent->fdset, &this->server_sock);
   }
   return TRUE;
 }