SO_KEEPALIVE can prevent stuck processes and is safe to enable
unconditionally on all TCP sockets (like git, and the rest of
public-inbox does).  Verified via strace on both NNTP and NNTPS
with and without nntp.proxy=socks5h://...
---
 lib/PublicInbox/NetReader.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index 403df952..28e20d38 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -182,6 +182,7 @@ sub nn_new ($$$) {
        } else {
                $nn = Net::NNTP->new(%$nn_arg) or return;
        }
+       setsockopt($nn, Socket::SOL_SOCKET(), Socket::SO_KEEPALIVE(), 1);
 
        # default to using STARTTLS if it's available, but allow
        # it to be disabled for localhost/VPN users
--
unsubscribe: one-click, see List-Unsubscribe header
archive: https://public-inbox.org/meta/

Reply via email to