diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-09-28 19:04:45 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-09-28 19:04:45 +0000 |
commit | 534d057e58e68c5a65509e718366f2dab5e69e84 (patch) | |
tree | 847cd2a9901e73ccb88f801c813842d857626af2 | |
parent | 4dc8ff965bea4226c36acae8880dc359e05414dd (diff) | |
download | ruby-534d057e58e68c5a65509e718366f2dab5e69e84.tar.gz |
* cont.c: Thread local storage should be fiber local.
* bootstraptest/test_knownbug.rb, test/ruby/test_fiber.rb:
move a fixed test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | bootstraptest/test_knownbug.rb | 28 | ||||
-rw-r--r-- | cont.c | 5 | ||||
-rw-r--r-- | test/ruby/test_fiber.rb | 29 | ||||
-rw-r--r-- | version.h | 6 |
5 files changed, 44 insertions, 31 deletions
@@ -1,3 +1,10 @@ +Sat Sep 29 03:53:26 2007 Koichi Sasada <ko1@atdot.net> + + * cont.c: Thread local storage should be fiber local. + + * bootstraptest/test_knownbug.rb, test/ruby/test_fiber.rb: + move a fixed test. + Fri Sep 28 23:15:31 2007 Yukihiro Matsumoto <matz@ruby-lang.org> * insnhelper.ci (vm_call_method): allow send! to call protected diff --git a/bootstraptest/test_knownbug.rb b/bootstraptest/test_knownbug.rb index 20533fa1b1..259ebc21ff 100644 --- a/bootstraptest/test_knownbug.rb +++ b/bootstraptest/test_knownbug.rb @@ -13,31 +13,3 @@ assert_finish 1, %q{ w.write "a" }, '[ruby-dev:31866]' -assert_equal "[[nil, 1, 3, 3, 1, nil, nil], [nil, 2, 2, nil]]", %q{ - def tvar(var, val) - old = Thread.current[var] - begin - Thread.current[var] = val - yield - ensure - Thread.current[var] = old - end - end - ary1 = [] - ary2 = [] - fb = Fiber.new { - ary2 << Thread.current[:v]; tvar(:v, 2) { - ary2 << Thread.current[:v]; Fiber.yield - ary2 << Thread.current[:v]; } - ary2 << Thread.current[:v]; Fiber.yield - ary2 << Thread.current[:v] - } - ary1 << Thread.current[:v]; tvar(:v,1) { - ary1 << Thread.current[:v]; tvar(:v,3) { - ary1 << Thread.current[:v]; fb.resume - ary1 << Thread.current[:v]; } - ary1 << Thread.current[:v]; } - ary1 << Thread.current[:v]; fb.resume - ary1 << Thread.current[:v]; - [ary1, ary2] -} @@ -86,6 +86,9 @@ cont_free(void *ptr) RUBY_FREE_UNLESS_NULL(cont->machine_register_stack); #endif RUBY_FREE_UNLESS_NULL(cont->vm_stack); + if (cont->saved_thread.local_storage) { + st_free_table(cont->saved_thread.local_storage); + } ruby_xfree(ptr); } RUBY_FREE_LEAVE("cont"); @@ -205,6 +208,7 @@ cont_restore_1(rb_context_t *cont) /* fiber */ th->stack = sth->stack; th->stack_size = sth->stack_size; + th->local_storage = sth->local_storage; th->fiber = cont->self; } else { @@ -500,6 +504,7 @@ fiber_alloc(VALUE klass, VALUE proc) th->cfp->proc = 0; th->cfp->block_iseq = 0; th->tag = 0; + th->local_storage = st_init_numtable(); th->first_proc = proc; diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index 2756e6b219..fc9a49919a 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -131,5 +131,34 @@ class TestFiber < Test::Unit::TestCase assert_equal(:ok, f1.transfer) assert_equal([:baz], ary) end + + def test_tls + # + def tvar(var, val) + old = Thread.current[var] + begin + Thread.current[var] = val + yield + ensure + Thread.current[var] = old + end + end + + fb = Fiber.new { + assert_equal(nil, Thread.current[:v]); tvar(:v, :x) { + assert_equal(:x, Thread.current[:v]); Fiber.yield + assert_equal(:x, Thread.current[:v]); } + assert_equal(nil, Thread.current[:v]); Fiber.yield + raise # unreachable + } + + assert_equal(nil, Thread.current[:v]); tvar(:v,1) { + assert_equal(1, Thread.current[:v]); tvar(:v,3) { + assert_equal(3, Thread.current[:v]); fb.resume + assert_equal(3, Thread.current[:v]); } + assert_equal(1, Thread.current[:v]); } + assert_equal(nil, Thread.current[:v]); fb.resume + assert_equal(nil, Thread.current[:v]); + end end @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2007-09-28" +#define RUBY_RELEASE_DATE "2007-09-29" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20070928 +#define RUBY_RELEASE_CODE 20070929 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2007 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 28 +#define RUBY_RELEASE_DAY 29 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; |