Skip to content

Commit ccef579

Browse files
committed
merge revision(s) 51213: [Backport ruby#11344]
* lib/timeout.rb (ExitException): removed internal exception class and use Timeout::Error instead, as using throw/catch to isolate each timeouts now. [ruby-dev:49179] [Bug ruby#11344] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 9580200 commit ccef579

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Mon Aug 17 16:51:45 2015 CHIKANAGA Tomoyuki <[email protected]>
2+
3+
* lib/timeout.rb (ExitException): leave Timeout::ExitException as an
4+
alias of Timeout::Error for backward compatibility in stable branch.
5+
[ruby-dev:49179] [Bug #11344]
6+
7+
Mon Aug 17 16:51:45 2015 Nobuyoshi Nakada <[email protected]>
8+
9+
* lib/timeout.rb (ExitException): removed internal exception class
10+
and use Timeout::Error instead, as using throw/catch to isolate
11+
each timeouts now. [ruby-dev:49179] [Bug #11344]
12+
113
Mon Aug 17 16:49:00 2015 Kazuhiro NISHIYAMA <[email protected]>
214

315
* test/net/http/test_httpresponse.rb

lib/timeout.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
module Timeout
2525
# Raised by Timeout#timeout when the block times out.
2626
class Error < RuntimeError
27-
end
28-
class ExitException < ::Exception # :nodoc:
2927
attr_reader :thread
3028

3129
def self.catch(*args)
@@ -48,6 +46,7 @@ def exception(*)
4846
self
4947
end
5048
end
49+
ExitException = Error
5150

5251
# :stopdoc:
5352
THIS_FILE = /\A#{Regexp.quote(__FILE__)}:/o
@@ -103,7 +102,7 @@ def timeout(sec, klass = nil) #:yield: +sec+
103102
bt = e.backtrace
104103
end
105104
else
106-
bt = ExitException.catch(message, &bl)
105+
bt = Error.catch(message, &bl)
107106
end
108107
rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o
109108
bt.reject! {|m| rej =~ m}

test/test_timeout.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def initialize(msg) super end
6363
end
6464

6565
def test_exit_exception
66-
assert_raise_with_message(Timeout::ExitException, "boon") do
67-
Timeout.timeout(10, Timeout::ExitException) do
68-
raise Timeout::ExitException, "boon"
66+
assert_raise_with_message(Timeout::Error, "boon") do
67+
Timeout.timeout(10, Timeout::Error) do
68+
raise Timeout::Error, "boon"
6969
end
7070
end
7171
end
@@ -80,4 +80,21 @@ def o.each
8080
Timeout.timeout(0.01) {e.next}
8181
end
8282
end
83+
84+
def test_handle_interrupt
85+
bug11344 = '[ruby-dev:49179] [Bug #11344]'
86+
ok = false
87+
assert_raise(Timeout::Error) {
88+
Thread.handle_interrupt(Timeout::Error => :never) {
89+
Timeout.timeout(0.01) {
90+
sleep 0.2
91+
ok = true
92+
Thread.handle_interrupt(Timeout::Error => :on_blocking) {
93+
sleep 0.2
94+
}
95+
}
96+
}
97+
}
98+
assert(ok, bug11344)
99+
end
83100
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.7"
22
#define RUBY_RELEASE_DATE "2015-08-17"
3-
#define RUBY_PATCHLEVEL 386
3+
#define RUBY_PATCHLEVEL 387
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 8

0 commit comments

Comments
 (0)