[PATCH xserver 05/23] os: Switch from select(2) to poll(2) in ErrorConnMax
Keith Packard
keithp at keithp.com
Thu May 26 23:59:40 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 4c1ba4b..488672c 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -892,16 +892,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