ruby-changes:13922
From: nobu <ko1@a...>
Date: Thu, 12 Nov 2009 13:57:55 +0900 (JST)
Subject: [ruby-changes:13922] Ruby:r25726 (trunk): * thread.c (thread_create_core): moved failure handling from
nobu 2009-11-12 13:57:39 +0900 (Thu, 12 Nov 2009) New Revision: 25726 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25726 Log: * thread.c (thread_create_core): moved failure handling from native_thread_core(). Modified files: trunk/ChangeLog trunk/thread.c trunk/thread_pthread.c trunk/thread_win32.c Index: thread_win32.c =================================================================== --- thread_win32.c (revision 25725) +++ thread_win32.c (revision 25726) @@ -479,8 +479,7 @@ th->thread_id = w32_create_thread(stack_size, thread_start_func_1, th); if ((th->thread_id) == 0) { - st_delete_wrap(th->vm->living_threads, th->self); - rb_raise(rb_eThreadError, "can't create Thread (%d)", errno); + return errno ? errno : -1; } w32_resume_thread(th->thread_id); Index: ChangeLog =================================================================== --- ChangeLog (revision 25725) +++ ChangeLog (revision 25726) @@ -1,5 +1,8 @@ -Thu Nov 12 13:31:00 2009 Nobuyoshi Nakada <nobu@r...> +Thu Nov 12 13:57:37 2009 Nobuyoshi Nakada <nobu@r...> + * thread.c (thread_create_core): moved failure handling from + native_thread_core(). + * thread_pthread.c (native_thread_create): constified. Thu Nov 12 10:08:56 2009 NARUSE, Yui <naruse@r...> Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 25725) +++ thread_pthread.c (revision 25726) @@ -509,11 +509,6 @@ if (!err) { pthread_cond_init(&th->native_thread_data.sleep_cond, 0); } - else { - st_delete_wrap(th->vm->living_threads, th->self); - th->status = THREAD_KILLED; - rb_raise(rb_eThreadError, "can't create Thread (%d)", err); - } } return err; } Index: thread.c =================================================================== --- thread.c (revision 25725) +++ thread.c (revision 25726) @@ -512,6 +512,7 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS)) { rb_thread_t *th; + int err; if (OBJ_FROZEN(GET_THREAD()->thgroup)) { rb_raise(rb_eThreadError, @@ -530,7 +531,12 @@ native_mutex_initialize(&th->interrupt_lock); /* kick thread */ st_insert(th->vm->living_threads, thval, (st_data_t) th->thread_id); - native_thread_create(th); + err = native_thread_create(th); + if (err) { + st_delete_wrap(th->vm->living_threads, th->self); + th->status = THREAD_KILLED; + rb_raise(rb_eThreadError, "can't create Thread (%d)", err); + } return thval; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/