ruby-changes:1972
From: ko1@a...
Date: 17 Sep 2007 05:42:31 +0900
Subject: [ruby-changes:1972] shyouhei - Ruby:r13463 (ruby_1_8_6): * ext/thread/thread.c (lock_mutex): should take care of threads
shyouhei 2007-09-17 05:42:15 +0900 (Mon, 17 Sep 2007)
New Revision: 13463
Modified files:
branches/ruby_1_8_6/ChangeLog
branches/ruby_1_8_6/ext/thread/thread.c
branches/ruby_1_8_6/test/thread/test_thread.rb
branches/ruby_1_8_6/version.h
Log:
* ext/thread/thread.c (lock_mutex): should take care of threads
not waiting any longer; there cases of a thread raising
exceptions. [ ruby-Bugs-11901 ]
* test/thread/test_thread.rb (test_mutex_exception_handling):
test for above.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/ChangeLog?r1=13463&r2=13462
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/version.h?r1=13463&r2=13462
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/ext/thread/thread.c?r1=13463&r2=13462
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/test/thread/test_thread.rb?r1=13463&r2=13462
Index: ruby_1_8_6/ext/thread/thread.c
===================================================================
--- ruby_1_8_6/ext/thread/thread.c (revision 13462)
+++ ruby_1_8_6/ext/thread/thread.c (revision 13463)
@@ -422,9 +422,8 @@
mutex->owner = current;
}
else {
- push_list(&mutex->waiting, current);
do {
- rb_thread_stop();
+ wait_list(&mutex->waiting);
rb_thread_critical = 1;
if (!MUTEX_LOCKED_P(mutex)) {
mutex->owner = current;
Index: ruby_1_8_6/ChangeLog
===================================================================
--- ruby_1_8_6/ChangeLog (revision 13462)
+++ ruby_1_8_6/ChangeLog (revision 13463)
@@ -1,3 +1,12 @@
+Mon Sep 17 05:24:13 2007 Sylvain Joyeux <sylvain.joyeux@m...>
+
+ * ext/thread/thread.c (lock_mutex): should take care of threads
+ not waiting any longer; there cases of a thread raising
+ exceptions. [ ruby-Bugs-11901 ]
+
+ * test/thread/test_thread.rb (test_mutex_exception_handling):
+ test for above.
+
Mon Sep 17 05:01:55 2007 Nobuyoshi Nakada <nobu@r...>
* runruby.rb: fix incomplete backport r12339.
Index: ruby_1_8_6/version.h
===================================================================
--- ruby_1_8_6/version.h (revision 13462)
+++ ruby_1_8_6/version.h (revision 13463)
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2007-09-17"
#define RUBY_VERSION_CODE 186
#define RUBY_RELEASE_CODE 20070917
-#define RUBY_PATCHLEVEL 105
+#define RUBY_PATCHLEVEL 106
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
Index: ruby_1_8_6/test/thread/test_thread.rb
===================================================================
--- ruby_1_8_6/test/thread/test_thread.rb (revision 13462)
+++ ruby_1_8_6/test/thread/test_thread.rb (revision 13463)
@@ -77,5 +77,43 @@
assert_equal("exit.", result[/.*\Z/], '[ruby-dev:30653]')
}
end
+
+ # This test checks that a thread in Mutex#lock which is raised is
+ # completely removed from the wait_list of the mutex
+ def test_mutex_exception_handling
+ m = Mutex.new
+ m.lock
+
+ sleeping = false
+ t = Thread.new do
+ begin
+ m.lock
+ rescue
+ end
+
+ sleeping = true
+ # Keep that thread alive: if the thread returns, the test method
+ # won't be able to check that +m+ has not been taken (dead mutex
+ # owners are ignored)
+ sleep
+ end
+
+ # Wait for t to wait for the mutex and raise it
+ while true
+ sleep 0.1
+ break if t.stop?
+ end
+ t.raise ArgumentError
+ assert(t.alive? || sleeping)
+
+ # Wait for +t+ to reach the sleep
+ while true
+ sleep 0.1
+ break if t.stop?
+ end
+
+ # Now unlock. The mutex should be free, so Mutex#unlock should return nil
+ assert(! m.unlock)
+ end
end
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml