[PATCH] Test WaitForSomething select return in new Check* functions
Keith Packard
keithp at keithp.com
Tue Jun 19 13:37:56 PDT 2012
The bitmask from select is only valid if it returned a positive value,
so record it for use by CheckWriteSocket and CheckReadSocket
Signed-off-by: Keith Packard <keithp at keithp.com>
---
os/WaitFor.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/os/WaitFor.c b/os/WaitFor.c
index bf03273..8f6f6eb 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -126,6 +126,7 @@ static OsTimerPtr timers = NULL;
static fd_set WriteSelectMask;
static Bool AnyWriteSelectMask;
static fd_set LastSelectWriteMask;
+static int LastSelectReturn;
/*****************
* AddWriteSocket:
@@ -163,7 +164,7 @@ RemoveWriteSocket(int fd)
Bool
CheckWriteSocket(int fd)
{
- return AnyWriteSelectMask && FD_ISSET(fd, &LastSelectWriteMask);
+ return LastSelectReturn > 0 && AnyWriteSelectMask && FD_ISSET(fd, &LastSelectWriteMask);
}
/*****************
@@ -176,7 +177,7 @@ CheckWriteSocket(int fd)
Bool
CheckReadSocket(int fd)
{
- return FD_ISSET(fd, &LastSelectMask);
+ return LastSelectReturn > 0 && FD_ISSET(fd, &LastSelectMask);
}
@@ -279,6 +280,7 @@ WaitForSomething(int *pClientsReady)
i = Select(MaxClients, &LastSelectMask, NULL, NULL, wt);
}
selecterr = GetErrno();
+ LastSelectReturn = i;
WakeupHandler(i, (pointer) &LastSelectMask);
if (i <= 0) { /* An error or timeout occurred */
if (dispatchException)
--
1.7.10
More information about the xorg-devel
mailing list