summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-22 03:39:26 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-22 03:39:26 +0000
commite66f118a9bf4e727ed63003af56a028779429482 (patch)
tree0f7aabb840ecbe53cedd4be521bc76870715b536
parent679e43eccb1f458deac7f8be824e17c98e79bead (diff)
* lib/rinda/tuplespace.rb: fix Rinda::TupleSpace keeper thread bug.
the thread is started too early. [ruby-talk:264062] * test/rinda/test_rinda.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@13222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--lib/rinda/tuplespace.rb13
-rw-r--r--test/rinda/test_rinda.rb14
-rw-r--r--version.h2
4 files changed, 30 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 56a7985..6186e20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun Arg 12 03:56:30 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * lib/rinda/tuplespace.rb: fix Rinda::TupleSpace keeper thread bug.
+ the thread is started too early. [ruby-talk:264062]
+
+ * test/rinda/test_rinda.rb: ditto.
+
Wed Aug 22 12:31:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (ac_cv_func_isinf): set yes also on OpenSolaris.
diff --git a/lib/rinda/tuplespace.rb b/lib/rinda/tuplespace.rb
index 73e79bb..6d58a0f 100644
--- a/lib/rinda/tuplespace.rb
+++ b/lib/rinda/tuplespace.rb
@@ -404,7 +404,6 @@ module Rinda
def write(tuple, sec=nil)
entry = TupleEntry.new(tuple, sec)
- start_keeper
synchronize do
if entry.expired?
@read_waiter.find_all_template(entry).each do |template|
@@ -414,6 +413,7 @@ module Rinda
notify_event('delete', entry.value)
else
@bag.push(entry)
+ start_keeper if entry.expires
@read_waiter.find_all_template(entry).each do |template|
template.read(tuple)
end
@@ -439,7 +439,6 @@ module Rinda
def move(port, tuple, sec=nil)
template = WaitTemplateEntry.new(self, tuple, sec)
yield(template) if block_given?
- start_keeper
synchronize do
entry = @bag.find(template)
if entry
@@ -452,6 +451,7 @@ module Rinda
begin
@take_waiter.push(template)
+ start_keeper if template.expires
while true
raise RequestCanceledError if template.canceled?
raise RequestExpiredError if template.expired?
@@ -476,7 +476,6 @@ module Rinda
def read(tuple, sec=nil)
template = WaitTemplateEntry.new(self, tuple, sec)
yield(template) if block_given?
- start_keeper
synchronize do
entry = @bag.find(template)
return entry.value if entry
@@ -484,6 +483,7 @@ module Rinda
begin
@read_waiter.push(template)
+ start_keeper if template.expires
template.wait
raise RequestCanceledError if template.canceled?
raise RequestExpiredError if template.expired?
@@ -566,8 +566,11 @@ module Rinda
def start_keeper
return if @keeper && @keeper.alive?
@keeper = Thread.new do
- while need_keeper?
- keep_clean
+ while true
+ synchronize do
+ break unless need_keeper?
+ keep_clean
+ end
sleep(@period)
end
end
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index d663e04..553d307 100644
--- a/test/rinda/test_rinda.rb
+++ b/test/rinda/test_rinda.rb
@@ -240,6 +240,20 @@ module TupleSpaceTestModule
end
end
+ def test_ruby_talk_264062
+ th = Thread.new { @ts.take([:empty], 1) }
+ sleep 2
+ assert_raises(Rinda::RequestExpiredError) do
+ th.value
+ end
+
+ th = Thread.new { @ts.read([:empty], 1) }
+ sleep 2
+ assert_raises(Rinda::RequestExpiredError) do
+ th.value
+ end
+ end
+
def test_core_01
5.times do |n|
@ts.write([:req, 2])
diff --git a/version.h b/version.h
index d8f8715..8628b7b 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2007-08-22"
#define RUBY_VERSION_CODE 186
#define RUBY_RELEASE_CODE 20070822
-#define RUBY_PATCHLEVEL 87
+#define RUBY_PATCHLEVEL 88
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8