James Gray
8/30/2006 3:48:00 PM
On Aug 30, 2006, at 7:38 AM, khaines@enigo.com wrote:
> On Wed, 30 Aug 2006, Noam Noam wrote:
>
>> Hi all,
>> when i'm using pstore with multi-users:
>> Permission denied - ../comments.dat.new
>> it seems that more then one user is asking to use the same file.
>> i tried to use synchronize for locking the transaction until it
>> finsh,
>> but it seems that i can not using it when i using pstore.
>> any one having any idea???
>> Thanks.
>
> pstore doesn't itself do any locking of any sort.
I don't think that's accurate. Here's part of the transaction()
method for PStore. Note the calls to flock():
def transaction(read_only=false) # :yields: pstore
# ...
unless read_only
file = File.open(@filename, File::RDWR | File::CREAT)
file.binmode
file.flock(File::LOCK_EX)
commit_new(file) if FileTest.exist?(new_file)
content = file.read()
else
begin
file = File.open(@filename, File::RDONLY)
file.binmode
file.flock(File::LOCK_SH)
content = (File.read(new_file) rescue file.read())
rescue Errno::ENOENT
content = ""
end
end
# ...
James Edward Gray II