Bug 9240 - EINTR in select causes client shutdown
Summary: EINTR in select causes client shutdown
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: 7.3 (2007.09)
Hardware: x86 (IA32) Linux (All)
: high major
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks: xorg-server-1.4.1
  Show dependency treegraph
 
Reported: 2006-12-04 09:14 UTC by Rich Coe
Modified: 2008-04-30 02:02 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Rich Coe 2006-12-04 09:14:10 UTC
in Xserver/os/connection.c, the Xserver calls CheckConnections() to check
the validity of the client file descriptors.  Even though the select is
called with a timeout of zero, it is still possible for the the OS to return
EINTR.  When this happens, an active client connection is dropped from the
server.

The LogWrite() is what I used to prove this is happening.  It can be removed.

N.B.: this patch includes the patch made for bug #7876.

--- xc/programs/Xserver/os/connection.c	2004-04-23 14:54:28.000000000 -0500
+++ xc/programs/Xserver/os/connection.c	2006-12-04 13:09:39.565957120 -0600
@@ -1056,8 +1056,11 @@ CheckConnections(void)
             FD_ZERO(&tmask);
             FD_SET(curclient, &tmask);
             r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
-            if (r < 0)
-		CloseDownClient(clients[ConnectionTranslation[curclient]]);
+	    if (r < 0 && GetConnectionTranslation(curclient) > 0)
+		LogWrite(1, "CheckConnections: close down client, errno %d\n", errno);
+		if ((EINTR != errno) && (EAGAIN != errno))
+		    CloseDownClient(clients[ConnectionTranslation[curclient]]);
+	    }
 	    mask &= ~((fd_mask)1 << curoff);
 	}
     }
Comment 1 Daniel Stone 2007-02-27 01:35:00 UTC
Sorry about the phenomenal bug spam, guys.  Adding xorg-team@ to the QA contact so bugs don't get lost in future.
Comment 2 Rich Coe 2007-11-19 17:48:16 UTC
I reviewed the current git version of xorg/xserver/os/connection.c,
and see that this problem still exists.  
Any way to get this fix in to xorg ?
Comment 3 Daniel Stone 2007-12-05 11:42:27 UTC
Thanks, I've pushed the fix for both to master, but want to wait until it's been properly tested until I cherry pick into the 1.4 branch.  Thanks for the patch.  I made a small modification: I made select continue until we stop getting either EINTR or EAGAIN, so we can actually determine whether or not the connection's dead.  Also, I applied it to the win32 part.
Comment 4 Daniel Stone 2007-12-05 11:42:43 UTC
(Leaving open only for 1.4.1.  It's fixed in master, I think.)
Comment 5 Daniel Stone 2008-04-30 02:02:26 UTC
This has even been pushed into 1.4 branch.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.