[commit: ghc] ghc-7.4: Disable the timer signal while blocked in select() (#5991) (6aee474)
Paolo Capriotti
p.capriotti at gmail.com
Thu Apr 12 16:31:21 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : ghc-7.4
http://hackage.haskell.org/trac/ghc/changeset/6aee474574e0aff10602a6fd17d37826b04a996d
>---------------------------------------------------------------
commit 6aee474574e0aff10602a6fd17d37826b04a996d
Author: Simon Marlow <marlowsd at gmail.com>
Date: Wed Apr 11 10:12:14 2012 +0100
Disable the timer signal while blocked in select() (#5991)
The threaded RTS had a fix for this a long time ago (#1623) but this
patch applies a similar fix to the non-threaded RTS.
MERGED from commit dd24d6bc37879c6b32a3d5ac4ee765e59e13501c
>---------------------------------------------------------------
rts/posix/Select.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/rts/posix/Select.c b/rts/posix/Select.c
index a3f2ae3..0b3f750 100644
--- a/rts/posix/Select.c
+++ b/rts/posix/Select.c
@@ -217,10 +217,19 @@ awaitEvent(rtsBool wait)
ptv = NULL;
}
- /* Check for any interesting events */
+ while (1) { // repeat the select on EINTR
- while ((numFound = select(maxfd+1, &rfd, &wfd, NULL, ptv)) < 0) {
- if (errno != EINTR) {
+ // Disable the timer signal while blocked in
+ // select(), to conserve power. (#1623, #5991)
+ if (wait) stopTimer();
+
+ numFound = select(maxfd+1, &rfd, &wfd, NULL, ptv);
+
+ if (wait) startTimer();
+
+ if (numFound >= 0) break;
+
+ if (errno != EINTR) {
/* Handle bad file descriptors by unblocking all the
waiting threads. Why? Because a thread might have been
a bit naughty and closed a file descriptor while another
More information about the Cvs-ghc
mailing list