Skip to content

Commit

Permalink
Merge pull request #51 from ruby/revert-21-patch-1
Browse files Browse the repository at this point in the history
Revert "Replace Timeout.timeout with socket timeout"
  • Loading branch information
tmtm authored Feb 14, 2023
2 parents 79d9a81 + aa777db commit 9e44412
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/net/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,7 @@ def digest_class
end

def tcp_socket(address, port)
begin
Socket.tcp address, port, nil, nil, connect_timeout: @open_timeout
rescue Errno::ETIMEDOUT #raise Net:OpenTimeout instead for compatibility with previous versions
raise Net::OpenTimeout, "Timeout to open TCP connection to "\
"#{address}:#{port} (exceeds #{@open_timeout} seconds)"
end
TCPSocket.open address, port
end

def do_start(helo_domain, user, secret, authtype)
Expand All @@ -653,7 +648,9 @@ def do_start(helo_domain, user, secret, authtype)
check_auth_method(authtype || DEFAULT_AUTH_TYPE)
check_auth_args user, secret
end
s = tcp_socket(@address, @port)
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
tcp_socket(@address, @port)
end
logging "Connection opened: #{@address}:#{@port}"
@socket = new_internet_message_io(tls? ? tlsconnect(s, @ssl_context_tls) : s)
check_response critical { recv_response() }
Expand Down

0 comments on commit 9e44412

Please sign in to comment.