diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-15 16:07:07 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-15 16:07:07 +0000 |
commit | 260d1ac2ca8711971c48e14bd535aeeb20f6ed1d (patch) | |
tree | efc07355499fc1baedbfeab41893d0e2edd214d7 /thread.c | |
parent | 59d521ade472e31affb1b3e925343adb95c89dd8 (diff) |
merge revision(s) 54598,54600: [Backport #12290]
* thread.c (get_initialized_threadptr): extract ensuring that the
thread is initialized.
* thread.c (rb_thread_setname): thread must be initialized to set
the name. [ruby-core:74963] [Bug #12290]
* thread.c (rb_thread_setname): defer setting native thread name
set in initialize until the native thread is created.
[ruby-core:74963] [Bug #12290]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -711,6 +711,8 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS)) return thval; } +#define threadptr_initialized(th) ((th)->first_args != 0) + /* * call-seq: * Thread.new { ... } -> thread @@ -742,7 +744,7 @@ thread_s_new(int argc, VALUE *argv, VALUE klass) rb_obj_call_init(thread, argc, argv); GetThreadPtr(thread, th); - if (!th->first_args) { + if (!threadptr_initialized(th)) { rb_raise(rb_eThreadError, "uninitialized thread - check `%"PRIsVALUE"#initialize'", klass); } @@ -2794,7 +2796,9 @@ rb_thread_setname(VALUE thread, VALUE name) } th->name = name; #if defined(SET_ANOTHER_THREAD_NAME) - SET_ANOTHER_THREAD_NAME(th->thread_id, s); + if (threadptr_initialized(th)) { + SET_ANOTHER_THREAD_NAME(th->thread_id, s); + } #endif return name; } |