aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-14 14:51:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-14 14:51:42 +0000
commit6c6a24826c5fda68e04e71ac17620b0e70bca265 (patch)
treec2692457fbae375c8a38fd64a90a852365e331fc /lib
parent1a760a6f76e5b2fad343fce10ebf831fe22286b4 (diff)
downloadruby-6c6a24826c5fda68e04e71ac17620b0e70bca265.tar.gz
* enum.c (enum_min_by): new method Enum#min_by. added Enum#max_by
as well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/cgi/session.rb4
-rw-r--r--lib/date.rb8
-rw-r--r--lib/thread.rb9
-rw-r--r--lib/timeout.rb1
4 files changed, 16 insertions, 6 deletions
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index cd6ce95f4d..a44de7cb81 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -365,7 +365,6 @@ class CGI
raise ArgumentError, "session_id `%s' is invalid" % id
end
@path = dir+"/"+prefix+id
- @path.untaint
unless File::exist? @path
@hash = {}
end
@@ -413,7 +412,8 @@ class CGI
# Close and delete the session's FileStore file.
def delete
- File::unlink @path
+ File::unlink @path
+ rescue Errno::ENOENT
end
end
diff --git a/lib/date.rb b/lib/date.rb
index b50e987852..b8c15a420a 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -711,7 +711,13 @@ class Date
alias_method :__#{id.to_i}__, :#{id.to_s}
private :__#{id.to_i}__
def #{id.to_s}(*args, &block)
- (@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0]
+ if @__#{id.to_i}__
+ @__#{id.to_i}__
+ elsif ! self.frozen?
+ @__#{id.to_i}__ ||= __#{id.to_i}__(*args, &block)
+ else
+ __#{id.to_i}__(*args, &block)
+ end
end
end;
end
diff --git a/lib/thread.rb b/lib/thread.rb
index 8b27356c48..a069c4680a 100644
--- a/lib/thread.rb
+++ b/lib/thread.rb
@@ -69,7 +69,7 @@ class Mutex
# Returns +true+ if this lock is currently held by some thread.
#
def locked?
- @locked
+ @locked && true
end
#
@@ -80,7 +80,7 @@ class Mutex
result = false
Thread.critical = true
unless @locked
- @locked = true
+ @locked = Thread.current
result = true
end
Thread.critical = false
@@ -92,10 +92,13 @@ class Mutex
#
def lock
while (Thread.critical = true; @locked)
+ if @locked == Thread.current
+ raise ThreadError, "deadlock; recursive locking"
+ end
@waiting.push Thread.current
Thread.stop
end
- @locked = true
+ @locked = Thread.current
Thread.critical = false
self
end
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 0ba5293d1d..7e3ee81ed0 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -35,6 +35,7 @@ module Timeout
def timeout(sec, exception=Error)
return yield if sec == nil or sec.zero?
+ raise ThreadError, "timeout within critical session" if Thread.critical
begin
x = Thread.current
y = Thread.start {