Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Socket options should be set again after a connection reset

  • Loading branch information...
commit 13e9e5575de83e2af264cd91155252e4370a1df4 1 parent 9f86179
@cmaion cmaion authored
Showing with 17 additions and 10 deletions.
  1. +17 −10 lib/net/http/persistent.rb
View
27 lib/net/http/persistent.rb
@@ -555,15 +555,7 @@ def connection_for uri
connection.open_timeout = @open_timeout if @open_timeout
connection.read_timeout = @read_timeout if @read_timeout
- connection.start
-
- socket = connection.instance_variable_get :@socket
-
- if socket then # for fakeweb
- @socket_options.each do |option|
- socket.io.setsockopt(*option)
- end
- end
+ start connection
end
connection
@@ -608,6 +600,21 @@ def expired? connection
end
##
+ # Starts the Net::HTTP +connection+
+
+ def start connection
+ connection.start
+
+ socket = connection.instance_variable_get :@socket
+
+ if socket then # for fakeweb
+ @socket_options.each do |option|
+ socket.io.setsockopt(*option)
+ end
+ end
+ end
+
+ ##
# Finishes the Net::HTTP +connection+
def finish connection, thread = Thread.current
@@ -812,7 +819,7 @@ def reset connection
finish connection
- connection.start
+ start connection
rescue Errno::ECONNREFUSED
raise Error, "connection refused: #{connection.address}:#{connection.port}"
rescue Errno::EHOSTDOWN
Please sign in to comment.
Something went wrong with that request. Please try again.