summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-08 06:24:25 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-08 06:24:25 +0000
commit1bb0917fa78b151729f8e40a98635ffd1ae72e09 (patch)
tree426e89b2ad8d019a65124ae4ec565b4a156e8cba
parent0b1e93285ec4dafefb8277425e1ff58e5247715c (diff)
merge revision(s) 27394:27397:
* lib/timeout.rb (Timeout#timeout): propagate errors to the caller. [ruby-dev:41010]' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@28209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/timeout.rb14
-rw-r--r--version.h2
3 files changed, 17 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index a360e46e25..efe43f5266 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jun 8 15:23:10 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/timeout.rb (Timeout#timeout): propagate errors to the
+ caller. [ruby-dev:41010]'
+
Tue Jun 8 15:15:18 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/net/smtp.rb (Net::SMTP#rcptto_list): fixed typo.
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 5a99c28092..e60b4e3f13 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -56,8 +56,13 @@ module Timeout
begin
x = Thread.current
y = Thread.start {
- sleep sec
- x.raise exception, "execution expired" if x.alive?
+ begin
+ sleep sec
+ rescue => e
+ x.raise e
+ else
+ x.raise exception, "execution expired" if x.alive?
+ end
}
yield sec
# return true
@@ -73,7 +78,10 @@ module Timeout
# would be expected outside.
raise Error, e.message, e.backtrace
ensure
- y.kill if y and y.alive?
+ 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 c0d9f70ea4..e56c88fe29 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2010-06-08"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20100608
-#define RUBY_PATCHLEVEL 273
+#define RUBY_PATCHLEVEL 274
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8