mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
59d521ade4
commit
260d1ac2ca
5 changed files with 26 additions and 7 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
Sat Apr 16 00:56:45 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* thread.c (rb_thread_setname): defer setting native thread name
|
||||||
|
set in initialize until the native thread is created.
|
||||||
|
[ruby-core:74963] [Bug #12290]
|
||||||
|
|
||||||
Fri Apr 15 21:10:00 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
Fri Apr 15 21:10:00 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||||
|
|
||||||
* lib/irb/ext/save-history.rb: Fix NoMethodError when method is not defined.
|
* lib/irb/ext/save-history.rb: Fix NoMethodError when method is not defined.
|
||||||
|
|
|
||||||
|
|
@ -1082,4 +1082,10 @@ q.pop
|
||||||
t.kill
|
t.kill
|
||||||
t.join
|
t.join
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_thread_setname_in_initialize
|
||||||
|
bug12290 = '[ruby-core:74963] [Bug #12290]'
|
||||||
|
c = Class.new(Thread) {def initialize() self.name = "foo"; super; end}
|
||||||
|
assert_equal("foo", c.new {Thread.current.name}.value)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
8
thread.c
8
thread.c
|
|
@ -711,6 +711,8 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS))
|
||||||
return thval;
|
return thval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define threadptr_initialized(th) ((th)->first_args != 0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Thread.new { ... } -> thread
|
* Thread.new { ... } -> thread
|
||||||
|
|
@ -742,7 +744,7 @@ thread_s_new(int argc, VALUE *argv, VALUE klass)
|
||||||
|
|
||||||
rb_obj_call_init(thread, argc, argv);
|
rb_obj_call_init(thread, argc, argv);
|
||||||
GetThreadPtr(thread, th);
|
GetThreadPtr(thread, th);
|
||||||
if (!th->first_args) {
|
if (!threadptr_initialized(th)) {
|
||||||
rb_raise(rb_eThreadError, "uninitialized thread - check `%"PRIsVALUE"#initialize'",
|
rb_raise(rb_eThreadError, "uninitialized thread - check `%"PRIsVALUE"#initialize'",
|
||||||
klass);
|
klass);
|
||||||
}
|
}
|
||||||
|
|
@ -2794,7 +2796,9 @@ rb_thread_setname(VALUE thread, VALUE name)
|
||||||
}
|
}
|
||||||
th->name = name;
|
th->name = name;
|
||||||
#if defined(SET_ANOTHER_THREAD_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
|
#endif
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1505,8 +1505,11 @@ native_set_thread_name(rb_thread_t *th)
|
||||||
{
|
{
|
||||||
#ifdef SET_CURRENT_THREAD_NAME
|
#ifdef SET_CURRENT_THREAD_NAME
|
||||||
if (!th->first_func && th->first_proc) {
|
if (!th->first_func && th->first_proc) {
|
||||||
VALUE loc = rb_proc_location(th->first_proc);
|
VALUE loc;
|
||||||
if (!NIL_P(loc)) {
|
if (!NIL_P(loc = th->name)) {
|
||||||
|
SET_CURRENT_THREAD_NAME(RSTRING_PTR(loc));
|
||||||
|
}
|
||||||
|
else if (!NIL_P(loc = rb_proc_location(th->first_proc))) {
|
||||||
const VALUE *ptr = RARRAY_CONST_PTR(loc); /* [ String, Fixnum ] */
|
const VALUE *ptr = RARRAY_CONST_PTR(loc); /* [ String, Fixnum ] */
|
||||||
char *name, *p;
|
char *name, *p;
|
||||||
char buf[16];
|
char buf[16];
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#define RUBY_VERSION "2.3.0"
|
#define RUBY_VERSION "2.3.0"
|
||||||
#define RUBY_RELEASE_DATE "2016-04-15"
|
#define RUBY_RELEASE_DATE "2016-04-16"
|
||||||
#define RUBY_PATCHLEVEL 81
|
#define RUBY_PATCHLEVEL 82
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2016
|
#define RUBY_RELEASE_YEAR 2016
|
||||||
#define RUBY_RELEASE_MONTH 4
|
#define RUBY_RELEASE_MONTH 4
|
||||||
#define RUBY_RELEASE_DAY 15
|
#define RUBY_RELEASE_DAY 16
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue