summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-31 00:12:27 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-31 00:12:27 +0000
commit67cf90f6a4c74b3e5c881447ce9a762237d347a2 (patch)
treedf8a6febf9116fef71060182805801a0add28a92
parent0c9c99ab0244281f6d71b1bbae48377c6e1f7384 (diff)
merges r31623 from trunk into ruby_1_9_2.
-- * lib/timeout.rb (Timeout#timeout): don't leak "execution expired" exception. [Bug #4283] [ruby-core:34534]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/timeout.rb32
-rw-r--r--version.h2
3 files changed, 23 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 8833f48240..92b11c8bcd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed May 18 20:25:04 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * lib/timeout.rb (Timeout#timeout): don't leak "execution expired"
+ exception. [Bug #4283] [ruby-core:34534].
+
Wed May 18 03:14:49 2011 Eric Hodel <drbrain@segment7.net>
* test/test_singleton.rb: Add tests from lib/singleton.rb. Patch by
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 297b76936c..aa0e7576d5 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -44,17 +44,24 @@ module Timeout
return yield(sec) if sec == nil or sec.zero?
exception = klass || Class.new(ExitException)
begin
- x = Thread.current
- y = Thread.start {
- begin
- sleep sec
- rescue => e
- x.raise e
- else
- x.raise exception, "execution expired" if x.alive?
+ begin
+ x = Thread.current
+ y = Thread.start {
+ begin
+ sleep sec
+ rescue => e
+ x.raise e
+ else
+ x.raise exception, "execution expired"
+ end
+ }
+ return yield(sec)
+ ensure
+ if y
+ y.kill
+ y.join # make sure y is dead.
end
- }
- return yield(sec)
+ end
rescue exception => e
rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o
(bt = e.backtrace).reject! {|m| rej =~ m}
@@ -66,11 +73,6 @@ module Timeout
raise if klass # if exception class is specified, it
# would be expected outside.
raise Error, e.message, e.backtrace
- ensure
- if y and y.alive?
- y.kill
- y.join # make sure y is dead.
- end
end
end
diff --git a/version.h b/version.h
index e3dde7db22..3025ae98f3 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 254
+#define RUBY_PATCHLEVEL 255
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1