[PATCH] [xorg/xserver] os/connection: Prevent WaitForSomething from busylooping

Erkki Seppälä erkki.seppala at vincit.fi
Tue Oct 4 06:11:52 PDT 2011


CheckConnections didn't check for write blocked clients. If an
ignored client is write-blocked but then closed, the Select in
WaitForSomething will return EBADF. CheckConnections is supposed to
weed these connections out but it doesn't, because it checks only for
AllClients, and ignored clients (which can still be written to) aren't
in that set.

This patch makes CheckConnections check also the set
ClientsWriteBlocked in addition to AllClients.

Test case: run cnee, put it in suspend with ^Z and generate a lot of
events, so that its connection becomes write blocked. Now kill -9 the
process and witness X entering a neverending loop. Cnee's connection
issues RecordEnableContext, which makes the connection ignored.

Signed-off-by: Erkki Seppälä <erkki.seppala at vincit.fi>
Reviewed-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
---
 os/connection.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/os/connection.c b/os/connection.c
index 1d38906..07021e7 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -993,7 +993,7 @@ CheckConnections(void)
 #ifndef WIN32
     for (i=0; i<howmany(XFD_SETSIZE, NFDBITS); i++)
     {
-	mask = AllClients.fds_bits[i];
+	mask = AllClients.fds_bits[i] | ClientsWriteBlocked.fds_bits[i];
         while (mask)
     	{
 	    curoff = mffs (mask) - 1;
-- 
1.7.0.4



More information about the xorg-devel mailing list