diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-08 10:46:27 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-08 10:46:27 +0000 |
commit | 19f52b87408263faba97f91404d84d4ef707bab6 (patch) | |
tree | f9f20acbe5e2387fc5473d6ea8bb022b9908db6b /thread_pthread.c | |
parent | 099933373211f74c00cc837fac26168b5d54ad2d (diff) |
* thread_pthread.c (native_cond_timedwait): add to care EINTR.
* thread_pthread.c (thread_timer): remove EINTR check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index 466fe36009..d14f2b25e5 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -292,10 +292,22 @@ native_cond_wait(rb_thread_cond_t *cond, pthread_mutex_t *mutex) static int native_cond_timedwait(rb_thread_cond_t *cond, pthread_mutex_t *mutex, struct timespec *ts) { - int r = pthread_cond_timedwait(&cond->cond, mutex, ts); - if (r != 0 && r != ETIMEDOUT && r != EINTR /* Linux */) { + int r; + + /* + * An old Linux may return EINTR. Even though POSIX says + * "These functions shall not return an error code of [EINTR]". + * http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_cond_timedwait.html + * Let's hide it from arch generic code. + */ + do { + r = pthread_cond_timedwait(&cond->cond, mutex, ts); + } while (r == EINTR); + + if (r != 0 && r != ETIMEDOUT) { rb_bug_errno("pthread_cond_timedwait", r); } + return r; } @@ -997,7 +1009,7 @@ thread_timer(void *dummy) err = native_cond_timedwait(&timer_thread_cond, &timer_thread_lock, &timeout); if (err == ETIMEDOUT); - else if (err == 0 || err == EINTR) { + else if (err == 0) { if (rb_signal_buff_size() == 0) break; } else rb_bug_errno("thread_timer/timedwait", err); |