ruby-changes:1731
From: ko1@a...
Date: 22 Aug 2007 12:39:34 +0900
Subject: [ruby-changes:1731] shyouhei - Ruby:r13222 (ruby_1_8_6): * lib/rinda/tuplespace.rb: fix Rinda::TupleSpace keeper thread bug.
shyouhei 2007-08-22 12:39:26 +0900 (Wed, 22 Aug 2007) New Revision: 13222 Modified files: branches/ruby_1_8_6/ChangeLog branches/ruby_1_8_6/lib/rinda/tuplespace.rb branches/ruby_1_8_6/test/rinda/test_rinda.rb branches/ruby_1_8_6/version.h Log: * 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. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/lib/rinda/tuplespace.rb?r1=13222&r2=13221 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/ChangeLog?r1=13222&r2=13221 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/version.h?r1=13222&r2=13221 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_6/test/rinda/test_rinda.rb?r1=13222&r2=13221 Index: ruby_1_8_6/ChangeLog =================================================================== --- ruby_1_8_6/ChangeLog (revision 13221) +++ ruby_1_8_6/ChangeLog (revision 13222) @@ -1,3 +1,10 @@ +Sun Arg 12 03:56:30 2007 Masatoshi SEKI <m_seki@m...> + + * 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@r...> * configure.in (ac_cv_func_isinf): set yes also on OpenSolaris. Index: ruby_1_8_6/version.h =================================================================== --- ruby_1_8_6/version.h (revision 13221) +++ ruby_1_8_6/version.h (revision 13222) @@ -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 Index: ruby_1_8_6/lib/rinda/tuplespace.rb =================================================================== --- ruby_1_8_6/lib/rinda/tuplespace.rb (revision 13221) +++ ruby_1_8_6/lib/rinda/tuplespace.rb (revision 13222) @@ -404,7 +404,6 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 Index: ruby_1_8_6/test/rinda/test_rinda.rb =================================================================== --- ruby_1_8_6/test/rinda/test_rinda.rb (revision 13221) +++ ruby_1_8_6/test/rinda/test_rinda.rb (revision 13222) @@ -240,6 +240,20 @@ 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]) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml