mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
net/imap: set SO_KEEPALIVE on TCP sockets
Otherwise connections (commonly on IDLE, but it could be any command) may never receive notifications of link errors. [ruby-core:86628] [Feature #14703] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
75e5a91e92
commit
c4056a4a70
1 changed files with 3 additions and 1 deletions
|
@ -1129,7 +1129,9 @@ module Net
|
|||
end
|
||||
|
||||
def tcp_socket(host, port)
|
||||
Socket.tcp(host, port, :connect_timeout => @open_timeout)
|
||||
s = Socket.tcp(host, port, :connect_timeout => @open_timeout)
|
||||
s.setsockopt(:SOL_SOCKET, :SO_KEEPALIVE, true)
|
||||
s
|
||||
rescue Errno::ETIMEDOUT
|
||||
raise Net::OpenTimeout, "Timeout to open TCP connection to " +
|
||||
"#{host}:#{port} (exceeds #{@open_timeout} seconds)"
|
||||
|
|
Loading…
Add table
Reference in a new issue