diff options
Diffstat (limited to 'lib/pstore.rb')
-rw-r--r-- | lib/pstore.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/pstore.rb b/lib/pstore.rb index 2aa9864b58..cc90207aa3 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -78,6 +78,16 @@ class PStore begin @transaction = true value = file = nil + lock = @filename + ".lock" + loop do + begin + File::symlink("pstore::#$$", lock) + break + rescue Errno::EEXIST + rescue + sleep 1 + end + end begin File::open(@filename, "r") do |file| @table = Marshal.load(file) @@ -112,6 +122,7 @@ class PStore ensure @table = nil @transaction = false + File::unlink(lock) end value end |