Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Timeout.timeout with socket timeout #21

Merged
merged 1 commit into from
Mar 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/net/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,12 @@ def finish
private

def tcp_socket(address, port)
TCPSocket.open 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
end

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