summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-22 21:21:06 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-22 21:21:06 +0000
commitc4056a4a702cb2e73d882ffa0729b66797660a18 (patch)
treea80ac02792cc059175857af23a456a1dbc4d8894 /lib
parent75e5a91e9224de4bebe7ed5e2e275f656cb4c662 (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/net/imap.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 3d33b94fdd..b42186dce0 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -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)"