]> Sergey Matveev's repositories - public-inbox.git/commitdiff
net_reader: set IMAPClient Keepalive flag late
authorEric Wong <e@80x24.org>
Thu, 9 Sep 2021 05:24:59 +0000 (05:24 +0000)
committerEric Wong <e@80x24.org>
Thu, 9 Sep 2021 05:42:55 +0000 (05:42 +0000)
Since we always enable SO_KEEPALIVE unconditionally, having it
in {mic_arg} leads to unnecessary IPC overhead and memory use.

lib/PublicInbox/NetReader.pm
lib/PublicInbox/Watch.pm

index b5d14f137d381d62f05b916b94acc519d88308af..9faa362c397acc5c110ac6271090b161f92a1bf2 100644 (file)
@@ -51,7 +51,7 @@ sub mic_new ($$$$) {
                $socks{Socket} = IO::Socket::Socks->new(%opt) or die
                        "E: <$$uri> ".eval('$IO::Socket::Socks::SOCKS_ERROR');
        }
-       PublicInbox::IMAPClient->new(%$mic_arg, %socks);
+       PublicInbox::IMAPClient->new(%$mic_arg, %socks, Keepalive => 1);
 }
 
 sub auth_anon_cb { '' }; # for Mail::IMAPClient::Authcallback
@@ -76,7 +76,6 @@ sub mic_for ($$$$) { # mic = Mail::IMAPClient
                Port => $uri->port,
                Server => $host,
                Ssl => $uri->scheme eq 'imaps',
-               Keepalive => 1, # SO_KEEPALIVE
                %$common, # may set Starttls, Compress, Debug ....
        };
        $mic_arg->{Ssl} = 1 if $uri->scheme eq 'imaps';
index 482d35c44687c583a6e3726b9bea4a1dc7f978ef..7a35ee59b0309b45f9b8c937cba400da4acc66a5 100644 (file)
@@ -358,7 +358,7 @@ sub watch_imap_idle_1 ($$$) {
        my $mic;
        local $0 = $uri->mailbox." $sec";
        until ($self->{quit}) {
-               $mic //= PublicInbox::IMAPClient->new(%$mic_arg);
+               $mic //= PublicInbox::IMAPClient->new(%$mic_arg,Keepalive => 1);
                my $err;
                if ($mic && $mic->IsConnected) {
                        local $self->{mics_cached}->{$sec} = $mic;