ruby-changes:25560
From: glass <ko1@a...>
Date: Sun, 11 Nov 2012 13:23:16 +0900 (JST)
Subject: [ruby-changes:25560] glass:r37617 (trunk): * lib/pstore.rb (PStore): fix not to replace ThreadError raised in
glass 2012-11-11 13:23:04 +0900 (Sun, 11 Nov 2012) New Revision: 37617 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37617 Log: * lib/pstore.rb (PStore): fix not to replace ThreadError raised in #transaction block with PStore::Error. [ruby-core:39238] [Bug #5269] Modified files: trunk/ChangeLog trunk/lib/pstore.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 37616) +++ ChangeLog (revision 37617) @@ -1,3 +1,9 @@ +Sun Nov 11 12:56:34 2012 Masaki Matsushita <glass.saga@g...> + + * lib/pstore.rb (PStore): fix not to replace ThreadError raised in + #transaction block with PStore::Error. + [ruby-core:39238] [Bug #5269] + Sun Nov 11 11:36:19 2012 Shugo Maeda <shugo@r...> * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): Index: lib/pstore.rb =================================================================== --- lib/pstore.rb (revision 37616) +++ lib/pstore.rb (revision 37617) @@ -309,8 +309,16 @@ # def transaction(read_only = false) # :yields: pstore value = nil - raise PStore::Error, "nested transaction" if !@thread_safe && @lock.locked? - @lock.synchronize do + if !@thread_safe + raise PStore::Error, "nested transaction" unless @lock.try_lock + else + begin + @lock.lock + rescue ThreadError + raise PStore::Error, "nested transaction" + end + end + begin @rdonly = read_only @abort = false file = open_and_lock_file(@filename, read_only) @@ -335,10 +343,10 @@ value = yield(self) end end + ensure + @lock.unlock end value - rescue ThreadError - raise PStore::Error, "nested transaction" end private -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/