summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-12 04:57:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-12 04:57:39 +0000
commit1d4183030db5824e745a901d625ad93af9ff2ec3 (patch)
treefdfccacfb2d122fd9ac04b486aef61664555d7b3 /thread.c
parenta360a8ce853ac66b822ceaf4453128891f7f2f62 (diff)
* thread.c (thread_create_core): moved failure handling from
native_thread_core(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/thread.c b/thread.c
index 11d3ed6335..5bca3e32af 100644
--- a/thread.c
+++ b/thread.c
@@ -512,6 +512,7 @@ static VALUE
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 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS))
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;
}