ruby-changes:5434
From: shyouhei <ko1@a...>
Date: Sun, 8 Jun 2008 03:52:39 +0900 (JST)
Subject: [ruby-changes:5434] Ruby:r16937 (ruby_1_8_5): merge revision(s) 13935:
shyouhei 2008-06-08 03:52:22 +0900 (Sun, 08 Jun 2008) New Revision: 16937 Modified files: branches/ruby_1_8_5/ChangeLog branches/ruby_1_8_5/lib/cgi/session.rb branches/ruby_1_8_5/version.h Log: merge revision(s) 13935: * lib/cgi/session.rb (CGI::Session::FileStore::restore): use lockfile for exclusive locks. a patch from <tommy AT tmtm.org>. [ruby-dev:32296] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/lib/cgi/session.rb?r1=16937&r2=16936&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/version.h?r1=16937&r2=16936&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/ChangeLog?r1=16937&r2=16936&diff_format=u Index: ruby_1_8_5/ChangeLog =================================================================== --- ruby_1_8_5/ChangeLog (revision 16936) +++ ruby_1_8_5/ChangeLog (revision 16937) @@ -1,3 +1,9 @@ +Sun Jun 8 03:50:40 2008 Yukihiro Matsumoto <matz@r...> + + * lib/cgi/session.rb (CGI::Session::FileStore::restore): use + lockfile for exclusive locks. a patch from <tommy AT tmtm.org>. + [ruby-dev:32296] + Sun Jun 8 03:46:55 2008 Tanaka Akira <akr@f...> * missing/isinf.c (isinf): don't define if the macro is defined. Index: ruby_1_8_5/version.h =================================================================== --- ruby_1_8_5/version.h (revision 16936) +++ ruby_1_8_5/version.h (revision 16937) @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2008-06-08" #define RUBY_VERSION_CODE 185 #define RUBY_RELEASE_CODE 20080608 -#define RUBY_PATCHLEVEL 146 +#define RUBY_PATCHLEVEL 147 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 Index: ruby_1_8_5/lib/cgi/session.rb =================================================================== --- ruby_1_8_5/lib/cgi/session.rb (revision 16936) +++ ruby_1_8_5/lib/cgi/session.rb (revision 16937) @@ -391,8 +391,9 @@ unless @hash @hash = {} begin + lockf = File.open(@path+".lock", "r") + lockf.flock File::LOCK_SH f = File.open(@path, 'r') - f.flock File::LOCK_SH for line in f line.chomp! k, v = line.split('=',2) @@ -400,6 +401,7 @@ end ensure f.close unless f.nil? + lockf.close if lockf end end @hash @@ -409,13 +411,17 @@ def update return unless @hash begin - f = File.open(@path, File::CREAT|File::TRUNC|File::RDWR, 0600) - f.flock File::LOCK_EX + lockf = File.open(@path+".lock", File::CREAT|File::RDWR, 0600) + lockf.flock File::LOCK_EX + f = File.open(@path+".new", File::CREAT|File::TRUNC|File::WRONLY, 0600) for k,v in @hash f.printf "%s=%s\n", CGI::escape(k), CGI::escape(String(v)) end + f.close + File.rename @path+".new", @path ensure - f.close unless f.nil? + f.close if f and !f.closed? + lockf.close if lockf end end @@ -426,6 +432,8 @@ # Close and delete the session's FileStore file. def delete + File::unlink @path+".lock" rescue nil + File::unlink @path+".new" rescue nil File::unlink @path rescue Errno::ENOENT end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/