Project

General

Profile

Bug #5765 » 0001-modernize-Timeout-usage-in-net-http-pop-smtp-telnet.patch

normalperson (Eric Wong), 12/15/2011 10:11 AM

View differences:

lib/net/http.rb
def connect
D "opening connection to #{conn_address()}..."
s = timeout(@open_timeout) { TCPSocket.open(conn_address(), conn_port()) }
s = Timeout.timeout(@open_timeout, Timeout::Error) do
TCPSocket.open(conn_address(), conn_port())
end
D "opened"
if use_ssl?
ssl_parameters = Hash.new
......
end
# Server Name Indication (SNI) RFC 3546
s.hostname = @address if s.respond_to? :hostname=
timeout(@open_timeout) { s.connect }
Timeout.timeout(@open_timeout, Timeout::Error) { s.connect }
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
s.post_connection_check(@address)
end
lib/net/pop.rb
# internal method for Net::POP3.start
def do_start(account, password) # :nodoc:
s = timeout(@open_timeout) { TCPSocket.open(@address, port) }
s = Timeout.timeout(@open_timeout, Timeout::Error) do
TCPSocket.open(@address, port)
end
if use_ssl?
raise 'openssl library not installed' unless defined?(OpenSSL)
context = OpenSSL::SSL::SSLContext.new
lib/net/smtp.rb
check_auth_method(authtype || DEFAULT_AUTH_TYPE)
check_auth_args user, secret
end
s = timeout(@open_timeout) { tcp_socket(@address, @port) }
s = Timeout.timeout(@open_timeout, Timeout::Error) do
tcp_socket(@address, @port)
end
logging "Connection opened: #{@address}:#{@port}"
@socket = new_internet_message_io(tls? ? tlsconnect(s) : s)
check_response critical { recv_response() }
lib/net/telnet.rb
if @options["Timeout"] == false
@sock = TCPSocket.open(@options["Host"], @options["Port"])
else
timeout(@options["Timeout"]) do
Timeout.timeout(@options["Timeout"], Timeout::Error) do
@sock = TCPSocket.open(@options["Host"], @options["Port"])
end
end
(1-1/2)