Commit 832f16f9 authored by Owen W. Taylor's avatar Owen W. Taylor Committed by John (J5) Palmieri
Browse files

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.
parent 2fd3aa9d
......@@ -217,7 +217,10 @@ pyg_signal_watch_new(void)
g_error("Cannot create main loop pipe: %s\n",
/* 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);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment