[ruby-core:63695] Re: [ruby-trunk - Bug #10031] [Open] Net::IMAP idle can still block a thread forever.

From: Eric Wong <normalperson@...>
Date: 2014-07-14 00:02:07 UTC
List: ruby-core #63695
Setting SO_KEEPALIVE on the socket will help, but that still takes at
least 2 hours to detect on a stock Linux system.  Do you want to set a
shorter keepalive, or is ~2 hours OK?

You can change the interval using OS-specific knobs (e.g. sysctl).

Totally untested one line patch here:

	--- a/lib/net/imap.rb
	+++ b/lib/net/imap.rb
	@@ -1053,6 +1053,7 @@ module Net
	       @tagno = 0
	       @parser = ResponseParser.new
	       @sock = TCPSocket.open(@host, @port)
	+      @sock.setsockopt(:SOL_SOCKET, :SO_KEEPALIVE, 1)
	       begin
		 if options[:ssl]
		   start_tls_session(options[:ssl])

In This Thread

Prev Next