summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-17 03:37:37 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-17 03:37:37 +0000
commite7de78da6b9f4975cf33f446abb944d1a15d522c (patch)
tree4dcbf1e7539167cb8846ef198fc46c679d636c22
parent093d264a0eefcd2ec0e969a17154c183cab3e2a1 (diff)
downloadruby-e7de78da6b9f4975cf33f446abb944d1a15d522c.tar.gz
ruby-e7de78da6b9f4975cf33f446abb944d1a15d522c.tar.xz
ruby-e7de78da6b9f4975cf33f446abb944d1a15d522c.zip
Kernel#.sleep used never to sleep on Mac OS X. Fixed it and added error checks.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--thread_pthread.c7
2 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index b52fdfe97..08d7f1f3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat May 17 12:34:54 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
+
+ * thread_pthread.c (Init_native_thread): Kernel#.sleep used never to
+ sleep on Mac OS X. Reported by arton <artonx AT yahoo.co.jp>.
+
+ * thread_pthread.c (native_sleep): added error checks.
+
Sat May 17 11:29:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_s_extname): first dot is not an extension name.
diff --git a/thread_pthread.c b/thread_pthread.c
index 30ffa8ca7..5ea391abd 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -149,6 +149,7 @@ Init_native_thread(void)
pthread_key_create(&ruby_native_thread_key, NULL);
th->thread_id = pthread_self();
+ native_cond_initialize(&th->native_thread_data.sleep_cond);
ruby_thread_set_native(th);
native_mutex_initialize(&signal_thread_list_lock);
posix_signal(SIGVTALRM, null_func);
@@ -432,9 +433,11 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
}
else {
if (tv == 0 || ts.tv_sec < tvn.tv_sec /* overflow */ ) {
+ int r;
thread_debug("native_sleep: pthread_cond_wait start\n");
- pthread_cond_wait(&th->native_thread_data.sleep_cond,
+ r = pthread_cond_wait(&th->native_thread_data.sleep_cond,
&th->interrupt_lock);
+ if (r) rb_bug("pthread_cond_wait: %d", r);
thread_debug("native_sleep: pthread_cond_wait end\n");
}
else {
@@ -443,6 +446,8 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
(unsigned long)ts.tv_sec, ts.tv_nsec);
r = pthread_cond_timedwait(&th->native_thread_data.sleep_cond,
&th->interrupt_lock, &ts);
+ if (r && r != ETIMEDOUT) rb_bug("pthread_cond_timedwait: %d", r);
+
thread_debug("native_sleep: pthread_cond_timedwait end (%d)\n", r);
}
}