Commit 126ebbae authored by sof's avatar sof
Browse files

[project @ 2002-07-24 03:38:58 by sof]

awaitEvent: if select() reports EBADF,
always unblock all waiting threads, even if
the prior invocation of select() also
elicited an EBADF.

The 'smart' that was there previously runs
the risk of working against us (if the EBADFs are
coming from different fds), so the above
scheme is preferable (and simpler.)
parent c952d3eb
/* -----------------------------------------------------------------------------
* $Id: Select.c,v 1.21 2002/07/17 09:21:51 simonmar Exp $
* $Id: Select.c,v 1.22 2002/07/24 03:38:58 sof Exp $
* (c) The GHC Team 1995-2002
......@@ -90,7 +90,6 @@ awaitEvent(rtsBool wait)
rtsBool select_succeeded = rtsTrue;
rtsBool unblock_all = rtsFalse;
static rtsBool prev_unblocked_all = rtsFalse;
struct timeval tv;
lnat min, ticks;
......@@ -188,12 +187,16 @@ awaitEvent(rtsBool wait)
should we see a bad file descriptor & give the threads
a chance to clean up their act.
To avoid getting stuck in a loop, repeated EBADF failures
are 'handled' through barfing.
Note: assume here that threads becoming unblocked
will try to read/write the file descriptor before trying
to issue a threadWaitRead/threadWaitWrite again (==> an
IOError will result for the thread that's got the bad
file descriptor.) Hence, there's no danger of a bad
file descriptor being repeatedly select()'ed on, so
the RTS won't loop.
if ( errno == EBADF && !prev_unblocked_all) {
if ( errno == EBADF ) {
unblock_all = rtsTrue;
prev_unblocked_all = rtsTrue;
} else {
fprintf(stderr,"%d\n", errno);
......@@ -208,8 +211,6 @@ awaitEvent(rtsBool wait)
#endif /* mingw32_TARGET_OS */
prev_unblocked_all = rtsFalse;
#ifndef mingw32_TARGET_OS
/* We got a signal; could be one of ours. If so, we need
* to start up the signal handler straight away, otherwise
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment