gst-plugins-base: multifdsink: disconnect inactive clients in the select loop too

Wim Taymans wtay at kemper.freedesktop.org
Thu Mar 10 06:11:10 PST 2011


Module: gst-plugins-base
Branch: master
Commit: 8c13488022051543d1d653e83e0d35b632a63646
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=8c13488022051543d1d653e83e0d35b632a63646

Author: Andoni Morales Alastruey <amorales at flumotion.com>
Date:   Fri Oct 22 14:01:26 2010 +0200

multifdsink: disconnect inactive clients in the select loop too

Clients are usually disconnected in the streaming thread if their inactivity
is bigger than the timeout. If no new buffers are to be rendered in the sink,
these clients will never be disconnected and for that reason it should be
handled in the select() loop too.

---

 gst/tcp/gstmultifdsink.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/gst/tcp/gstmultifdsink.c b/gst/tcp/gstmultifdsink.c
index 4072eef..00cff05 100644
--- a/gst/tcp/gstmultifdsink.c
+++ b/gst/tcp/gstmultifdsink.c
@@ -2447,10 +2447,34 @@ gst_multi_fd_sink_handle_clients (GstMultiFdSink * sink)
      * - client socket input (ie, clients saying goodbye)
      * - client socket output (ie, client reads)          */
     GST_LOG_OBJECT (sink, "waiting on action on fdset");
-    result = gst_poll_wait (sink->fdset, GST_CLOCK_TIME_NONE);
 
-    /* < 0 is an error, 0 just means a timeout happened, which is impossible */
-    if (result < 0) {
+    result = gst_poll_wait (sink->fdset, sink->timeout != 0 ? sink->timeout :
+        GST_CLOCK_TIME_NONE);
+
+    /* Handle the special case in which the sink is not receiving more buffers
+     * and will not disconnect innactive client in the streaming thread. */
+    if (G_UNLIKELY (result == 0)) {
+      GstClockTime now;
+      GTimeVal nowtv;
+
+      g_get_current_time (&nowtv);
+      now = GST_TIMEVAL_TO_TIME (nowtv);
+
+      CLIENTS_LOCK (sink);
+      for (clients = sink->clients; clients; clients = next) {
+        GstTCPClient *client;
+
+        client = (GstTCPClient *) clients->data;
+        next = g_list_next (clients);
+        if (sink->timeout > 0
+            && now - client->last_activity_time > sink->timeout) {
+          client->status = GST_CLIENT_STATUS_SLOW;
+          gst_multi_fd_sink_remove_client_link (sink, clients);
+        }
+      }
+      CLIENTS_UNLOCK (sink);
+      return;
+    } else if (result < 0) {
       GST_WARNING_OBJECT (sink, "wait failed: %s (%d)", g_strerror (errno),
           errno);
       if (errno == EBADF) {



More information about the gstreamer-commits mailing list