ruby-changes:19442
From: kosaki <ko1@a...>
Date: Sun, 8 May 2011 19:46:34 +0900 (JST)
Subject: [ruby-changes:19442] Ruby:r31482 (trunk): * thread_pthread.c (native_cond_timedwait): add to care EINTR.
kosaki 2011-05-08 19:46:27 +0900 (Sun, 08 May 2011) New Revision: 31482 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31482 Log: * thread_pthread.c (native_cond_timedwait): add to care EINTR. * thread_pthread.c (thread_timer): remove EINTR check. Modified files: trunk/ChangeLog trunk/thread_pthread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 31481) +++ ChangeLog (revision 31482) @@ -1,3 +1,8 @@ +Sun May 8 19:39:16 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * thread_pthread.c (native_cond_timedwait): add to care EINTR. + * thread_pthread.c (thread_timer): remove EINTR check. + Sun May 8 19:04:15 2011 Tadayoshi Funaba <tadf@d...> * lib/time.rb (xmlschema): avoid passing any negative numbers. Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 31481) +++ thread_pthread.c (revision 31482) @@ -292,10 +292,22 @@ 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 @@ 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/