]> Sergey Matveev's repositories - public-inbox.git/commitdiff
net_reader: set SO_KEEPALIVE on all Net::NNTP sockets
authorEric Wong <e@80x24.org>
Sat, 18 Sep 2021 09:33:31 +0000 (09:33 +0000)
committerEric Wong <e@80x24.org>
Sat, 18 Sep 2021 20:25:59 +0000 (20:25 +0000)
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

index a5aab65024fedadf64ac6b04de12c9ac151a5a08..ccfdd26194a3f3056266411b70edb5a3441c1452 100644 (file)
@@ -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