Added file lock and improved read of file.

This commit is contained in:
Martin Edenhofer 2013-04-15 16:09:07 +02:00
parent 9283d70e9e
commit 57d1d8288b

View file

@ -66,15 +66,14 @@ module Session
data = nil
return if !File.exist? session_file
File.open( session_file, 'rb' ) { |file|
all = ''
while line = file.gets
all = all + line
end
file.flock( File::LOCK_EX )
all = file.read
begin
data = Marshal.load( all )
rescue
return
end
file.flock( File::LOCK_UN )
}
return data
end