summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-20 04:34:14 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-20 04:34:14 +0000
commit39fb0d4c51c26e8c7e061bd885a8106924e6ddc0 (patch)
tree10dc48fe45c7714540858394da15340b021d9bf4 /lib
parent6141b9c82be7825f54c71ab0247dce948be0711d (diff)
downloadruby-39fb0d4c51c26e8c7e061bd885a8106924e6ddc0.tar.gz
ruby-39fb0d4c51c26e8c7e061bd885a8106924e6ddc0.tar.xz
ruby-39fb0d4c51c26e8c7e061bd885a8106924e6ddc0.zip
* numeric.c (flo_eq): alway check if operands are NaN.
[ruby-list:39685] * lib/cgi/session.rb: use LOCK_SH to read, and a few other improvements. [ruby-core:02328] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@6372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/cgi/session.rb49
-rw-r--r--lib/mkmf.rb2
2 files changed, 25 insertions, 26 deletions
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 7115cae7d..cd6ce95f4 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -364,16 +364,11 @@ class CGI
unless check_id(id)
raise ArgumentError, "session_id `%s' is invalid" % id
end
- path = dir+"/"+prefix+id
- path.untaint
- unless File::exist? path
+ @path = dir+"/"+prefix+id
+ @path.untaint
+ unless File::exist? @path
@hash = {}
end
- begin
- @f = open(path, "r+")
- rescue Errno::ENOENT
- @f = open(path, "w+")
- end
end
# Restore session state from the session's FileStore file.
@@ -382,13 +377,17 @@ class CGI
def restore
unless @hash
@hash = {}
- @f.flock File::LOCK_EX
- @f.rewind
- for line in @f
- line.chomp!
- k, v = line.split('=',2)
- @hash[CGI::unescape(k)] = CGI::unescape(v)
- end
+ begin
+ f = File.open(@path, 'r')
+ f.flock File::LOCK_SH
+ for line in f
+ line.chomp!
+ k, v = line.split('=',2)
+ @hash[CGI::unescape(k)] = CGI::unescape(v)
+ end
+ ensure
+ f.close unless f.nil?
+ end
end
@hash
end
@@ -396,25 +395,25 @@ class CGI
# Save session state to the session's FileStore file.
def update
return unless @hash
- @f.rewind
- for k,v in @hash
- @f.printf "%s=%s\n", CGI::escape(k), CGI::escape(String(v))
- end
- @f.truncate @f.tell
+ begin
+ f = File.open(@path, 'w')
+ 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
# Update and close the session's FileStore file.
def close
- return if @f.closed?
update
- @f.close
end
# Close and delete the session's FileStore file.
def delete
- path = @f.path
- @f.close
- File::unlink path
+ File::unlink @path
end
end
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index c8e98fb4e..a95fb7e32 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -603,7 +603,7 @@ def check_sizeof(type, header = nil, &b)
end
message(a = size ? "#{size}\n" : "failed\n")
Logging::message "-------------------- %s\n", a
- r
+ size
end
def find_executable0(bin, path = nil)