From 126ebbae699dc0d3dcd5f8b6e25907132e47a668 Mon Sep 17 00:00:00 2001 From: sof Date: Wed, 24 Jul 2002 03:38:58 +0000 Subject: [PATCH] [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.) --- ghc/rts/Select.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ghc/rts/Select.c b/ghc/rts/Select.c index a2c990e..dc19cbf 100644 --- a/ghc/rts/Select.c +++ b/ghc/rts/Select.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $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) #endif 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; break; } else { fprintf(stderr,"%d\n", errno); @@ -208,8 +211,6 @@ awaitEvent(rtsBool wait) #endif /* mingw32_TARGET_OS */ ACQUIRE_LOCK(&sched_mutex); - 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 -- 1.7.10.4