Skip to content

Commit 13e40bd

Browse files
author
wyhaines
committed
lib/monitor.rb: Backport ruby#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 ruby#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
1 parent 885527d commit 13e40bd

File tree

4 files changed

+50
-10
lines changed

4 files changed

+50
-10
lines changed

ChangeLog

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
Wed June 9 01:05:00 Kirk Haines <khaines@ruby-lang.org>
2+
3+
* lib/monitor.rb: Backport #2240 [ruby-core:26185]; backport r25420 to ensure that the scheduled thread is alive when a monitor is released.
4+
* test/monitor/test_monitor.rb: Backport #2240 [ruby-core:26185]; added a test for the above functionality.
5+
6+
17
Tue Jun 8 23:45:00 2010 Kirk Haines <khaines@ruby-lang.org>
28

3-
* regexp.c: Backport #3403; backported from r28192 to fix a bug with non-greedy matching.
4-
* test/ruby/test_regexp.rb: Backport #3403; added this test suite, commenting out inapplicable tests to the current 1.8.6.
5-
* ChangeLog: Got my date wrong in the last few entries. Tuesday is the 8th, not the 9th!
9+
* regexp.c: Backport #3403; backported from r28192 to fix a bug with non-greedy matching. r28231
10+
* test/ruby/test_regexp.rb: Backport #3403; added this test suite, commenting out inapplicable tests to the current 1.8.6. r28231
11+
* ChangeLog: Got my date wrong in the last few entries. Tuesday is the 8th, not the 9th! r28231
612

713
Tue Jun 8 20:40:00 2010 Kirk Haines <khaines@ruby-lang.org>
814

lib/monitor.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,15 @@ def mon_acquire(queue)
288288
@mon_owner = Thread.current
289289
end
290290

291+
# mon_release requires Thread.critical == true
291292
def mon_release
292293
@mon_owner = nil
293-
t = @mon_waiting_queue.shift
294-
t = @mon_entering_queue.shift unless t
295-
t.wakeup if t
294+
while t = @mon_waiting_queue.shift || @mon_entering_queue.shift
295+
if t.alive?
296+
t.wakeup
297+
return
298+
end
299+
end
296300
end
297301

298302
def mon_enter_for_cond(count)

test/monitor/test_monitor.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,32 @@ def test_synchronize
5454
assert_equal((1..10).to_a, ary)
5555
end
5656

57+
def test_killed_thread_in_synchronize
58+
ary = []
59+
queue = Queue.new
60+
t1 = Thread.start {
61+
queue.pop
62+
@monitor.synchronize {
63+
ary << :t1
64+
}
65+
}
66+
t2 = Thread.start {
67+
queue.pop
68+
@monitor.synchronize {
69+
ary << :t2
70+
}
71+
}
72+
@monitor.synchronize do
73+
queue.enq(nil)
74+
queue.enq(nil)
75+
assert_equal([], ary)
76+
t1.kill
77+
t2.kill
78+
ary << :main
79+
end
80+
assert_equal([:main], ary)
81+
end
82+
5783
def test_try_enter
5884
queue1 = Queue.new
5985
queue2 = Queue.new
@@ -94,6 +120,10 @@ def test_cond
94120
assert_equal(true, result1)
95121
assert_equal("bar", a)
96122
end
123+
end
124+
125+
def test_timedwait
126+
cond = @monitor.new_cond
97127

98128
b = "foo"
99129
queue2 = Queue.new

version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#define RUBY_VERSION "1.8.6"
2-
#define RUBY_RELEASE_DATE "2010-06-08"
2+
#define RUBY_RELEASE_DATE "2010-06-09"
33
#define RUBY_VERSION_CODE 186
4-
#define RUBY_RELEASE_CODE 20100608
5-
#define RUBY_PATCHLEVEL 407
4+
#define RUBY_RELEASE_CODE 20100609
5+
#define RUBY_PATCHLEVEL 408
66

77
#define RUBY_VERSION_MAJOR 1
88
#define RUBY_VERSION_MINOR 8
99
#define RUBY_VERSION_TEENY 6
1010
#define RUBY_RELEASE_YEAR 2010
1111
#define RUBY_RELEASE_MONTH 6
12-
#define RUBY_RELEASE_DAY 8
12+
#define RUBY_RELEASE_DAY 9
1313

1414
#ifdef RUBY_EXTERN
1515
RUBY_EXTERN const char ruby_version[];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy