From a5b9624fdc645b836980e38c6e1109f3584ab43a Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 10 May 2014 15:52:45 +0000 Subject: thread_pthread.c: variable for errno * thread_pthread.c (rb_thread_wakeup_timer_thread_fd): use a local variable for errno. * thread_pthread.c (consume_communication_pipe): ditto. add EWOULDBLOCK case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'thread_pthread.c') diff --git a/thread_pthread.c b/thread_pthread.c index 0df64237ce..848051afd1 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1238,7 +1238,8 @@ rb_thread_wakeup_timer_thread_fd(int fd) const char *buff = "!"; retry: if ((result = write(fd, buff, 1)) <= 0) { - switch (errno) { + int e = errno; + switch (e) { case EINTR: goto retry; case EAGAIN: #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN @@ -1246,7 +1247,7 @@ rb_thread_wakeup_timer_thread_fd(int fd) #endif break; default: - rb_async_bug_errno("rb_thread_wakeup_timer_thread - write", errno); + rb_async_bug_errno("rb_thread_wakeup_timer_thread - write", e); } } if (TT_DEBUG) WRITE_CONST(2, "rb_thread_wakeup_timer_thread: write\n"); @@ -1283,13 +1284,17 @@ consume_communication_pipe(int fd) return; } else if (result < 0) { - switch (errno) { - case EINTR: + int e = errno; + switch (e) { + case EINTR: continue; /* retry */ - case EAGAIN: + case EAGAIN: +#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN + case EWOULDBLOCK: +#endif return; - default: - rb_async_bug_errno("consume_communication_pipe: read\n", errno); + default: + rb_async_bug_errno("consume_communication_pipe: read\n", e); } } } -- cgit v1.2.3