* lib/pstore.rb (PStore): fix not to replace ThreadError raised in
#transaction block with PStore::Error. [ruby-core:39238] [Bug #5269] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ba5ea548ce
commit
fc4b6cd25f
@ -1,3 +1,9 @@
|
|||||||
|
Sun Nov 11 12:56:34 2012 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Sun Nov 11 11:36:19 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo):
|
* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo):
|
||||||
|
@ -309,8 +309,16 @@ class PStore
|
|||||||
#
|
#
|
||||||
def transaction(read_only = false) # :yields: pstore
|
def transaction(read_only = false) # :yields: pstore
|
||||||
value = nil
|
value = nil
|
||||||
raise PStore::Error, "nested transaction" if !@thread_safe && @lock.locked?
|
if !@thread_safe
|
||||||
@lock.synchronize do
|
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
|
@rdonly = read_only
|
||||||
@abort = false
|
@abort = false
|
||||||
file = open_and_lock_file(@filename, read_only)
|
file = open_and_lock_file(@filename, read_only)
|
||||||
@ -335,10 +343,10 @@ class PStore
|
|||||||
value = yield(self)
|
value = yield(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
@lock.unlock
|
||||||
end
|
end
|
||||||
value
|
value
|
||||||
rescue ThreadError
|
|
||||||
raise PStore::Error, "nested transaction"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
Loading…
x
Reference in New Issue
Block a user