[PATCH xserver 19/25] os: Use poll(2) instead of select(2) in ErrorConnMax

Keith Packard keithp at keithp.com
Wed May 25 05:38:56 UTC 2016


This avoids problems if the file descriptor is too large for select(2)

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 os/connection.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/os/connection.c b/os/connection.c
index be82610..6b74c76 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -877,16 +877,12 @@ ErrorConnMax(XtransConnInfo trans_conn)
     struct iovec iov[3];
     char order = 0;
     int whichbyte = 1;
-    struct timeval waittime;
-    fd_set mask;
+    struct pollfd poll_fd;
 
     /* if these seems like a lot of trouble to go to, it probably is */
-    waittime.tv_sec = BOTIMEOUT / MILLI_PER_SECOND;
-    waittime.tv_usec = (BOTIMEOUT % MILLI_PER_SECOND) *
-        (1000000 / MILLI_PER_SECOND);
-    FD_ZERO(&mask);
-    FD_SET(fd, &mask);
-    (void) Select(fd + 1, &mask, NULL, NULL, &waittime);
+    poll_fd.fd = fd;
+    poll_fd.events = POLLIN;
+    (void) poll(&poll_fd, 1, BOTIMEOUT);
     /* try to read the byte-order of the connection */
     (void) _XSERVTransRead(trans_conn, &order, 1);
     if (order == 'l' || order == 'B' || order == 'r' || order == 'R') {
-- 
2.8.0.rc3



More information about the xorg-devel mailing list