From f809a87f70f0937a87b5d3a83704847daceef4dd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 20 May 2011 19:50:34 -0700 Subject: Kgio.poll: ensure EINTR never gets raised Retry on a zero timeout if we get interrupted even if the timeout expired. This is also what IO.select does in Ruby itself. --- ext/kgio/poll.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ext/kgio/poll.c') diff --git a/ext/kgio/poll.c b/ext/kgio/poll.c index 2f101d1..89f4623 100644 --- a/ext/kgio/poll.c +++ b/ext/kgio/poll.c @@ -40,8 +40,6 @@ static int retryable(struct poll_args *a) if (a->timeout < 0) return 1; - if (a->timeout == 0) - return 0; clock_gettime(hopefully_CLOCK_MONOTONIC, &ts); @@ -53,7 +51,9 @@ static int retryable(struct poll_args *a) } a->timeout -= ts.tv_sec * 1000; a->timeout -= ts.tv_nsec / 1000000; - return (a->timeout >= 0); + if (a->timeout < 0) + a->timeout = 0; + return 1; } static int num2timeout(VALUE timeout) -- cgit v1.2.3-24-ge0c7