From 1845686fa00493ca3a9667b330066300ff900323 Mon Sep 17 00:00:00 2001 From: marha Date: Sun, 19 Sep 2010 18:55:31 +0000 Subject: Make sure that both AllClients and AllSockets contain valid sockets in checkconnections --- xorg-server/os/connection.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'xorg-server') diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c index cc3873f9a..24632f1c0 100644 --- a/xorg-server/os/connection.c +++ b/xorg-server/os/connection.c @@ -1008,7 +1008,8 @@ CheckConnections(void) struct timeval notime; int r; #ifdef WIN32 - fd_set savedAllClients; + fd_set savedAllSockets; + unsigned j; #endif notime.tv_sec = 0; @@ -1034,19 +1035,23 @@ CheckConnections(void) } } #else - XFD_COPYSET(&AllClients, &savedAllClients); - for (i = 0; i < XFD_SETCOUNT(&savedAllClients); i++) + XFD_COPYSET(&AllSockets, &savedAllSockets); + for (j=0; j<2; j++) { - curclient = XFD_FD(&savedAllClients, i); - FD_ZERO(&tmask); - FD_SET(curclient, &tmask); - do { - r = Select (curclient + 1, &tmask, NULL, NULL, ¬ime); - } while (r < 0 && (errno == EINTR || errno == EAGAIN)); - if (r < 0) - if (GetConnectionTranslation(curclient) > 0) - CloseDownClient(clients[GetConnectionTranslation(curclient)]); - } + for (i = 0; i < XFD_SETCOUNT(&savedAllSockets); i++) + { + curclient = XFD_FD(&savedAllSockets, i); + FD_ZERO(&tmask); + FD_SET(curclient, &tmask); + do { + r = Select (curclient + 1, &tmask, NULL, NULL, ¬ime); + } while (r < 0 && (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEWOULDBLOCK)); + if (r < 0) + if (GetConnectionTranslation(curclient) > 0) + CloseDownClient(clients[GetConnectionTranslation(curclient)]); + } + XFD_COPYSET(&AllClients, &savedAllSockets); + } #endif } -- cgit v1.2.3