user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/8] net_reader: set IMAPClient Keepalive flag late
Date: Thu,  9 Sep 2021 05:24:59 +0000	[thread overview]
Message-ID: <20210909052505.7174-3-e@80x24.org> (raw)
In-Reply-To: <20210909052505.7174-1-e@80x24.org>

Since we always enable SO_KEEPALIVE unconditionally, having it
in {mic_arg} leads to unnecessary IPC overhead and memory use.
---
 lib/PublicInbox/NetReader.pm | 3 +--
 lib/PublicInbox/Watch.pm     | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index b5d14f13..9faa362c 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -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';
diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm
index 482d35c4..7a35ee59 100644
--- a/lib/PublicInbox/Watch.pm
+++ b/lib/PublicInbox/Watch.pm
@@ -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;

  parent reply	other threads:[~2021-09-09  5:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  5:24 [PATCH 0/8] net_reader: simplify + fix bugs Eric Wong
2021-09-09  5:24 ` [PATCH 1/8] net_reader: do not set "SSL" fields for non-TLS Eric Wong
2021-09-09  5:24 ` Eric Wong [this message]
2021-09-09  5:25 ` [PATCH 3/8] net_reader: preserve memoized IMAPClient arg for SOCKS Eric Wong
2021-09-09  5:25 ` [PATCH 4/8] net_reader: nntp_opt => cfg_opt Eric Wong
2021-09-09  5:25 ` [PATCH 5/8] net_reader: imap_opt " Eric Wong
2021-09-09  5:25 ` [PATCH 6/8] net_reader: combine Net::NNTP and IMAPClient args Eric Wong
2021-09-09  5:25 ` [PATCH 7/8] net_reader: improve naming of common args Eric Wong
2021-09-09  5:25 ` [PATCH 8/8] net_reader: support Mail::IMAPClient Ignoresizeerrors Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909052505.7174-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).