diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-28 12:46:27 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-28 12:46:27 +0000 |
commit | 16d4733ee49d749e4dad3de896a3f02e0573eeff (patch) | |
tree | 57644e641f3658b367efcd78f4881f83498a9906 /thread_pthread.c | |
parent | bc8b1008731e5aadca308c464b184066e2856e76 (diff) |
* thread_pthread.c (thread_start_func_1): initialize native thread
data immediately before starting.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index 8a10d3a217..797399b97e 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -324,6 +324,8 @@ ruby_thread_set_native(rb_thread_t *th) return pthread_setspecific(ruby_native_thread_key, th) == 0; } +static void native_thread_init(rb_thread_t *th); + void Init_native_thread(void) { @@ -331,11 +333,17 @@ Init_native_thread(void) pthread_key_create(&ruby_native_thread_key, NULL); th->thread_id = pthread_self(); + native_thread_init(th); + native_mutex_initialize(&signal_thread_list_lock); + posix_signal(SIGVTALRM, null_func); +} + +static void +native_thread_init(rb_thread_t *th) +{ native_cond_initialize(&th->native_thread_data.sleep_cond); native_cond_initialize(&th->native_thread_data.gvl_cond); ruby_thread_set_native(th); - native_mutex_initialize(&signal_thread_list_lock); - posix_signal(SIGVTALRM, null_func); } static void @@ -519,6 +527,7 @@ thread_start_func_1(void *th_ptr) #ifndef __CYGWIN__ native_thread_init_stack(th); #endif + native_thread_init(th); /* run */ thread_start_func_2(th, &stack_start, rb_ia64_bsp()); } @@ -679,10 +688,6 @@ native_thread_create(rb_thread_t *th) err = pthread_create(&th->thread_id, &attr, thread_start_func_1, th); thread_debug("create: %p (%d)", (void *)th, err); CHECK_ERR(pthread_attr_destroy(&attr)); - - if (!err) { - pthread_cond_init(&th->native_thread_data.sleep_cond, 0); - } } return err; } |