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
This commit is contained in:
nobu 2014-05-10 15:52:45 +00:00
parent 3385f6a0d4
commit a5b9624fdc

View File

@ -1238,7 +1238,8 @@ rb_thread_wakeup_timer_thread_fd(int fd)
const char *buff = "!"; const char *buff = "!";
retry: retry:
if ((result = write(fd, buff, 1)) <= 0) { if ((result = write(fd, buff, 1)) <= 0) {
switch (errno) { int e = errno;
switch (e) {
case EINTR: goto retry; case EINTR: goto retry;
case EAGAIN: case EAGAIN:
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
@ -1246,7 +1247,7 @@ rb_thread_wakeup_timer_thread_fd(int fd)
#endif #endif
break; break;
default: 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"); if (TT_DEBUG) WRITE_CONST(2, "rb_thread_wakeup_timer_thread: write\n");
@ -1283,13 +1284,17 @@ consume_communication_pipe(int fd)
return; return;
} }
else if (result < 0) { else if (result < 0) {
switch (errno) { int e = errno;
case EINTR: switch (e) {
case EINTR:
continue; /* retry */ continue; /* retry */
case EAGAIN: case EAGAIN:
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
return; return;
default: default:
rb_async_bug_errno("consume_communication_pipe: read\n", errno); rb_async_bug_errno("consume_communication_pipe: read\n", e);
} }
} }
} }