From: nobu@... Date: 2006-07-30T10:11:54+09:00 Subject: Re: many many warnings... Hi, At Sun, 30 Jul 2006 01:43:47 +0900, Tom Allison wrote in [ruby-talk:204896]: > I run my fcgi script under ruby -w. > I don't think these are related to the FileStore storage that I'm using, > rather the PStore. Is this something that can be fixed or am I doing it > wrong? Does this make it gentle? Index: lib/cgi/session.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/cgi/session.rb,v retrieving revision 1.23.2.15 diff -p -u -2 -r1.23.2.15 session.rb --- lib/cgi/session.rb 7 Mar 2005 00:20:15 -0000 1.23.2.15 +++ lib/cgi/session.rb 30 Jul 2006 01:07:01 -0000 @@ -302,7 +302,5 @@ class CGI # Retrieve the session data for key +key+. def [](key) - unless @data - @data = @dbman.restore - end + @data ||= @dbman.restore @data[key] end @@ -310,10 +308,6 @@ class CGI # Set the session date for key +key+. def []=(key, val) - unless @write_lock - @write_lock = true - end - unless @data - @data = @dbman.restore - end + @write_lock ||= true + @data ||= @dbman.restore @data[key] = val end @@ -375,5 +369,5 @@ class CGI def initialize(session, option={}) dir = option['tmpdir'] || Dir::tmpdir - prefix = option['prefix'] || '' + prefix = option['prefix'] || '' suffix = option['suffix'] || '' id = session.session_id @@ -381,5 +375,7 @@ class CGI md5 = Digest::MD5.hexdigest(id)[0,16] @path = dir+"/"+prefix+md5+suffix - unless File::exist? @path + if File::exist? @path + @hash = nil + else unless session.new_session raise CGI::Session::NoSession, "uninitialized session" cvs diff: Diffing lib/cgi/session Index: lib/cgi/session/pstore.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/cgi/session/pstore.rb,v retrieving revision 1.3.2.5 diff -p -u -2 -r1.3.2.5 pstore.rb --- lib/cgi/session/pstore.rb 15 Dec 2004 01:54:37 -0000 1.3.2.5 +++ lib/cgi/session/pstore.rb 30 Jul 2006 01:09:17 -0000 @@ -15,15 +15,4 @@ require 'pstore' class CGI class Session - def []=(key, val) - unless @write_lock - @write_lock = true - end - unless @data - @data = @dbman.restore - end - #@data[key] = String(val) - @data[key] = val - end - # PStore-based session storage class. # @@ -54,5 +43,5 @@ class CGI # This session's PStore file will be created if it does # not exist, or opened if it does. - def initialize session, option={} + def initialize(session, option={}) dir = option['tmpdir'] || Dir::tmpdir prefix = option['prefix'] || '' @@ -62,5 +51,7 @@ class CGI path = dir+"/"+prefix+md5 path.untaint - unless File::exist?(path) + if File::exist?(path) + @hash = nil + else unless session.new_session raise CGI::Session::NoSession, "uninitialized session" -- Nobu Nakada