Permalink
Browse files

fixes for blocking timeouts in 1.8.7

  • Loading branch information...
1 parent 551169e commit 19a1535ca00903cc167168703246e1b91dba248e @geemus geemus committed Aug 14, 2012
Showing with 18 additions and 6 deletions.
  1. +18 −6 lib/excon/socket.rb
View
@@ -36,8 +36,12 @@ def connect
if @params[:nonblock]
socket.connect_nonblock(sockaddr)
else
- Timeout.timeout(@params[:connect_timeout], Excon::Errors::Timeout.new('connect timeout reached')) do
- socket.connect(sockaddr)
+ begin
+ Timeout.timeout(@params[:connect_timeout]) do
+ socket.connect(sockaddr)
+ end
+ rescue Timeout::Error
+ raise Excon::Errors::Timeout.new('connect timeout reached')
end
end
@@ -112,8 +116,12 @@ def read(max_length=nil)
@read_buffer.slice!(0, @read_buffer.length)
end
else
- Timeout.timeout(@params[:read_timeout], Excon::Errors::Timeout.new('read timeout reached')) do
- @socket.read(max_length)
+ begin
+ Timeout.timeout(@params[:read_timeout]) do
+ @socket.read(max_length)
+ end
+ rescue Timeout::Error
+ raise Excon::Errors::Timeout.new('read timeout reached')
end
end
end
@@ -163,8 +171,12 @@ def write(data)
end
end
else
- Timeout.timeout(@params[:write_timeout], Excon::Errors::Timeout.new('write timeout reached')) do
- @socket.write(data)
+ begin
+ Timeout.timeout(@params[:write_timeout]) do
+ @socket.write(data)
+ end
+ rescue Timeout::Error
+ Excon::Errors::Timeout.new('write timeout reached')
@zimbatm
zimbatm Dec 27, 2013 Contributor

I think this exception is meant to be raised.

@zimbatm
zimbatm Dec 27, 2013 Contributor

Submitted in #349 :)

@geemus
geemus Dec 27, 2013 Contributor

good catch

end
end
end

0 comments on commit 19a1535

Please sign in to comment.