diff options
author | wyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-08 16:35:10 +0000 |
---|---|---|
committer | wyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-08 16:35:10 +0000 |
commit | 13e40bdaa08d004edb45c2be872a812236296f31 (patch) | |
tree | f085e807f29f7859a588f0b5aefb061429086275 | |
parent | 885527dec71812e613ecd77b2cdfb7f448b52664 (diff) |
lib/monitor.rb: Backport #2240 [ruby-core:26185]; backport r25420 to ensure that the scheduled thread is alive when a monitor is released.
test/monitor/test_monitor.rb: Backport #2240 [ruby-core:26185]; added a test for the above functionality.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@28232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | lib/monitor.rb | 10 | ||||
-rw-r--r-- | test/monitor/test_monitor.rb | 30 | ||||
-rw-r--r-- | version.h | 8 |
4 files changed, 50 insertions, 10 deletions
@@ -1,8 +1,14 @@ +Wed June 9 01:05:00 Kirk Haines <khaines@ruby-lang.org> + + * lib/monitor.rb: Backport #2240 [ruby-core:26185]; backport r25420 to ensure that the scheduled thread is alive when a monitor is released. + * test/monitor/test_monitor.rb: Backport #2240 [ruby-core:26185]; added a test for the above functionality. + + Tue Jun 8 23:45:00 2010 Kirk Haines <khaines@ruby-lang.org> - * regexp.c: Backport #3403; backported from r28192 to fix a bug with non-greedy matching. - * test/ruby/test_regexp.rb: Backport #3403; added this test suite, commenting out inapplicable tests to the current 1.8.6. - * ChangeLog: Got my date wrong in the last few entries. Tuesday is the 8th, not the 9th! + * regexp.c: Backport #3403; backported from r28192 to fix a bug with non-greedy matching. r28231 + * test/ruby/test_regexp.rb: Backport #3403; added this test suite, commenting out inapplicable tests to the current 1.8.6. r28231 + * ChangeLog: Got my date wrong in the last few entries. Tuesday is the 8th, not the 9th! r28231 Tue Jun 8 20:40:00 2010 Kirk Haines <khaines@ruby-lang.org> diff --git a/lib/monitor.rb b/lib/monitor.rb index 4c146c8086..9158f9fb32 100644 --- a/lib/monitor.rb +++ b/lib/monitor.rb @@ -288,11 +288,15 @@ module MonitorMixin @mon_owner = Thread.current end + # mon_release requires Thread.critical == true def mon_release @mon_owner = nil - t = @mon_waiting_queue.shift - t = @mon_entering_queue.shift unless t - t.wakeup if t + while t = @mon_waiting_queue.shift || @mon_entering_queue.shift + if t.alive? + t.wakeup + return + end + end end def mon_enter_for_cond(count) diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb index b539cb3cca..71d2ed19a5 100644 --- a/test/monitor/test_monitor.rb +++ b/test/monitor/test_monitor.rb @@ -54,6 +54,32 @@ class TestMonitor < Test::Unit::TestCase assert_equal((1..10).to_a, ary) end + def test_killed_thread_in_synchronize + ary = [] + queue = Queue.new + t1 = Thread.start { + queue.pop + @monitor.synchronize { + ary << :t1 + } + } + t2 = Thread.start { + queue.pop + @monitor.synchronize { + ary << :t2 + } + } + @monitor.synchronize do + queue.enq(nil) + queue.enq(nil) + assert_equal([], ary) + t1.kill + t2.kill + ary << :main + end + assert_equal([:main], ary) + end + def test_try_enter queue1 = Queue.new queue2 = Queue.new @@ -94,6 +120,10 @@ class TestMonitor < Test::Unit::TestCase assert_equal(true, result1) assert_equal("bar", a) end + end + + def test_timedwait + cond = @monitor.new_cond b = "foo" queue2 = Queue.new @@ -1,15 +1,15 @@ #define RUBY_VERSION "1.8.6" -#define RUBY_RELEASE_DATE "2010-06-08" +#define RUBY_RELEASE_DATE "2010-06-09" #define RUBY_VERSION_CODE 186 -#define RUBY_RELEASE_CODE 20100608 -#define RUBY_PATCHLEVEL 407 +#define RUBY_RELEASE_CODE 20100609 +#define RUBY_PATCHLEVEL 408 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_TEENY 6 #define RUBY_RELEASE_YEAR 2010 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 8 +#define RUBY_RELEASE_DAY 9 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; |