Bug #5269 » patch.diff
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
|
||
@lock.lock rescue ThreadError raise PStore::Error, "nested transaction"
|
||
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
|