Commit 37936e2b authored by Erik de Castro Lopo's avatar Erik de Castro Lopo Committed by Ben Gamari
Browse files

rts/posix/Itimer.c: Handle EINTR when reading timerfd

Commit 8626d76a added checking of the return value when reading from
the `timer_fd` and calling `sysErrorBelch` to print a warning message.
However some error causes (like EINTR) are benign and should just be
ignored.

Test Plan: validate

Reviewers: hvr, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2040

(cherry picked from commit 7aa4c52f)
parent 1547b9cf
......@@ -202,10 +202,15 @@ static void *itimer_thread_func(void *_handle_tick)
while (1) {
if (USE_TIMERFD_FOR_ITIMER) {
if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks))
sysErrorBelch("Itimer: read(timer_fd) failed");
if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) {
if (errno != EINTR) {
sysErrorBelch("Itimer: read(timerfd) failed");
}
}
} else {
usleep(TimeToUS(itimer_interval));
if (usleep(TimeToUS(itimer_interval)) != 0 && errno != EINTR) {
sysErrorBelch("usleep(TimeToUS(itimer_interval) failed");
}
}
switch (itimer_state) {
case RUNNING:
......@@ -222,7 +227,7 @@ static void *itimer_thread_func(void *_handle_tick)
return NULL;
}
}
return NULL;
return NULL; // Never reached.
}
#endif
......
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