gstpoll: retry reading the control socket to release properly all wakeups
authorAndoni Morales Alastruey <ylatuya@gmail.com>
Mon, 4 Apr 2011 01:33:46 +0000 (03:33 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 4 Apr 2011 09:05:45 +0000 (11:05 +0200)
if set->control_pending is set to 0 but we didn't not succed reading
the control socket, future calls to gst_poll_wait() will be awaiken
by the control socket which will not be released properly because
set->control_pending is already 0, causing an infinite loop.

gst/gstpoll.c

index fbcf2b2..76a7a30 100644 (file)
@@ -210,8 +210,11 @@ release_all_wakeup (GstPoll * set)
     /* try to remove all pending control messages */
     if (g_atomic_int_compare_and_exchange (&set->control_pending, old, 0)) {
       /* we managed to remove all messages, read the control socket */
-      (void) RELEASE_EVENT (set);
-      break;
+      if (RELEASE_EVENT (set))
+        break;
+      else
+        /* retry again until we read it successfully */
+        g_atomic_int_exchange_and_add (&set->control_pending, 1);
     }
   }
   return old;