diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-15 03:20:52 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-15 03:20:52 +0000 |
commit | af2ab37334cdd70ad4d0a7e859ded4653dcc391c () | |
tree | 7d92ddcf173900b2056d4fdb0a2302a981945ad6 /lib/cgi/session.rb | |
parent | 4c56aaa162645ff29e5524271d38a6cf1113aa61 (diff) |
* lib/cgi/session.rb (CGI::Session::FileStore::restore): use
lockfile for exclusive locks. a from <tommy AT tmtm.org>. [ruby-dev:32296] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/cgi/session.rb | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -397,8 +397,9 @@ class CGI unless @hash @hash = {} begin f = File.open(@path, 'r') - f.flock File::LOCK_SH for line in f line.chomp! k, v = line.split('=',2) @@ -406,6 +407,7 @@ class CGI end ensure f.close unless f.nil? end end @hash @@ -415,13 +417,17 @@ class CGI def update return unless @hash begin - f = File.open(@path, File::CREAT|File::TRUNC|File::RDWR, 0600) - f.flock File::LOCK_EX for k,v in @hash f.printf "%s=%s\n", CGI::escape(k), CGI::escape(String(v)) end ensure - f.close unless f.nil? end end @@ -432,6 +438,8 @@ class CGI # Close and delete the session's FileStore file. def delete File::unlink @path rescue Errno::ENOENT end |