Project

General

Profile

Bug #5269 » patch.diff

Glass_saga (Masaki Matsushita), 09/23/2011 08:47 PM

View differences:

lib/pstore.rb
#
def transaction(read_only = false, &block) # :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)
......
value = yield(self)
end
end
ensure
@lock.unlock
end
value
rescue ThreadError
raise PStore::Error, "nested transaction"
end
private
(2-2/2)