[pygobject] pygmainloop: avoid lockups if multiple glib.MainLoop exist



commit 832f16f96815adc22cc3acbeb3fa969631795a29
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sun Oct 30 18:08:57 2011 -0400

    pygmainloop: avoid lockups if multiple glib.MainLoop exist
    
    If multiple glib.MainLoop() sources exist, then we will add multiple
    watches, and when python writes a byte to the wakeup pipe, all of the
    sources will try to read it; only one will succeed and the others
    will block. Set both ends of the pipe nonblocking to avoid this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=663068

 gi/_glib/pygmainloop.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/gi/_glib/pygmainloop.c b/gi/_glib/pygmainloop.c
index 614a662..43dcf92 100644
--- a/gi/_glib/pygmainloop.c
+++ b/gi/_glib/pygmainloop.c
@@ -217,7 +217,10 @@ pyg_signal_watch_new(void)
 	    g_error("Cannot create main loop pipe: %s\n",
 	            g_strerror(errno));
 
-        /* Make the write end of the fd non blocking */
+        /* Make both ends of the fd non blocking */
+        flag = fcntl(pipe_fds[0], F_GETFL, 0);
+        flag |= O_NONBLOCK;
+        fcntl(pipe_fds[0], F_SETFL, flag);
         flag = fcntl(pipe_fds[1], F_GETFL, 0);
         flag |= O_NONBLOCK;
         fcntl(pipe_fds[1], F_SETFL, flag);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]