ruby-changes:4951
From: ko1@a...
Date: Sat, 17 May 2008 12:37:59 +0900 (JST)
Subject: [ruby-changes:4951] yugui - Ruby:r16444 (trunk): Kernel#.sleep used never to sleep on Mac OS X. Fixed it and added error checks.
yugui 2008-05-17 12:37:37 +0900 (Sat, 17 May 2008)
New Revision: 16444
Modified files:
trunk/ChangeLog
trunk/thread_pthread.c
Log:
Kernel#.sleep used never to sleep on Mac OS X. Fixed it and added error checks.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16444&r2=16443&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/thread_pthread.c?r1=16444&r2=16443&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 16443)
+++ ChangeLog (revision 16444)
@@ -1,3 +1,10 @@
+Sat May 17 12:34:54 2008 Yuki Sonoda (Yugui) <yugui@y...>
+
+ * 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@r...>
* file.c (rb_file_s_extname): first dot is not an extension name.
Index: thread_pthread.c
===================================================================
--- thread_pthread.c (revision 16443)
+++ thread_pthread.c (revision 16444)
@@ -149,6 +149,7 @@
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 @@
}
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 @@
(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);
}
}
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/