[pulseaudio-commits] src/pulse

Tanu Kaskinen tanuk at kemper.freedesktop.org
Fri Jun 6 05:37:09 PDT 2014


 src/pulse/mainloop.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

New commits:
commit fe346cadedd2a9b48fc36886c4a8d48f50302f07
Author: Pierre Ossman <ossman at cendio.se>
Date:   Fri Sep 20 10:26:30 2013 +0200

    mainloop: avoid race-y double wakeup status
    
    Having an extra variable that tracks the wakeup status introduces a
    race where the variable is set but the data has yet to propagate from
    the write end of the pipe to the read end. When this happens the
    system goes into a tight loop as select() always returns immediately.

diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c
index 66a1475..5ef58ff 100644
--- a/src/pulse/mainloop.c
+++ b/src/pulse/mainloop.c
@@ -114,7 +114,6 @@ struct pa_mainloop {
     int retval;
     bool quit:1;
 
-    pa_atomic_t wakeup_requested;
     int wakeup_pipe[2];
     int wakeup_pipe_type;
 
@@ -774,8 +773,6 @@ void pa_mainloop_wakeup(pa_mainloop *m) {
     if (pa_write(m->wakeup_pipe[1], &c, sizeof(c), &m->wakeup_pipe_type) < 0)
         /* Not much options for recovering from the error. Let's at least log something. */
         pa_log("pa_write() failed while trying to wake up the mainloop: %s", pa_cstrerror(errno));
-
-    pa_atomic_store(&m->wakeup_requested, true);
 }
 
 static void clear_wakeup(pa_mainloop *m) {
@@ -783,10 +780,8 @@ static void clear_wakeup(pa_mainloop *m) {
 
     pa_assert(m);
 
-    if (pa_atomic_cmpxchg(&m->wakeup_requested, true, false)) {
-        while (pa_read(m->wakeup_pipe[0], &c, sizeof(c), &m->wakeup_pipe_type) == sizeof(c))
-            ;
-    }
+    while (pa_read(m->wakeup_pipe[0], &c, sizeof(c), &m->wakeup_pipe_type) == sizeof(c))
+        ;
 }
 
 int pa_mainloop_prepare(pa_mainloop *m, int timeout) {



More information about the pulseaudio-commits mailing list