summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2012-04-11 10:12:14 +0100
committerSimon Marlow <marlowsd@gmail.com>2012-04-11 11:39:13 +0100
commitdd24d6bc37879c6b32a3d5ac4ee765e59e13501c (patch)
tree47fffd35ddf8456d3d7a296d6fbb3fa74b870f11 /rts
parentd6e3f3d2b71e28a00e1c180dd411346e058787c1 (diff)
downloadhaskell-dd24d6bc37879c6b32a3d5ac4ee765e59e13501c.tar.gz
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.
Diffstat (limited to 'rts')
-rw-r--r--rts/posix/Select.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/rts/posix/Select.c b/rts/posix/Select.c
index 1edf6bc690..dc40b706d8 100644
--- a/rts/posix/Select.c
+++ b/rts/posix/Select.c
@@ -196,10 +196,19 @@ awaitEvent(rtsBool wait)
ptv = NULL;
}
- /* Check for any interesting events */
-
- while ((numFound = select(maxfd+1, &rfd, &wfd, NULL, ptv)) < 0) {
- if (errno != EINTR) {
+ while (1) { // repeat the select on 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