* [PATCH 4/5] imap: mailboxes list across listeners
2022-08-08 23:53 6% [PATCH 0/5] daemon/netd-related improvements Eric Wong
@ 2022-08-08 23:53 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2022-08-08 23:53 UTC (permalink / raw)
To: meta
Since IMAP mailbox lists are tied to the PublicInbox::Config
object, we can share them the same way the config object is
shared when an -imapd or -netd instance has multiple listeners.
This ought to reduce memory use and startup time when binding
multiple sockets which share a common config file.
---
lib/PublicInbox/IMAPD.pm | 49 ++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/lib/PublicInbox/IMAPD.pm b/lib/PublicInbox/IMAPD.pm
index dd0d2c53..ba6ad05d 100644
--- a/lib/PublicInbox/IMAPD.pm
+++ b/lib/PublicInbox/IMAPD.pm
@@ -23,7 +23,7 @@ sub new {
}, $class;
}
-sub imapd_refresh_ibx { # pi_cfg->each_inbox cb
+sub _refresh_ibx { # pi_cfg->each_inbox cb
my ($ibx, $imapd, $cache, $dummies) = @_;
my $ngname = $ibx->{newsgroup} // return;
@@ -56,27 +56,32 @@ sub imapd_refresh_ibx { # pi_cfg->each_inbox cb
sub refresh_groups {
my ($self, $sig) = @_;
my $pi_cfg = PublicInbox::Config->new;
- my $mailboxes = $self->{mailboxes} = {};
- my $cache = eval { $pi_cfg->ALL->misc->nntpd_cache_load } // {};
- my $dummies = {};
- $pi_cfg->each_inbox(\&imapd_refresh_ibx, $self, $cache, $dummies);
- %$dummies = (%$dummies, %$mailboxes);
- $mailboxes = $self->{mailboxes} = $dummies;
- @{$self->{mailboxlist}} = map { $_->[2] }
- sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] }
- map {
- my $u = $_; # capitalize "INBOX" for user-familiarity
- $u =~ s/\Ainbox(\.|\z)/INBOX$1/i;
- if ($mailboxes->{$_} == $dummy) {
- [ $u, -1,
- qq[* LIST (\\HasChildren) "." $u\r\n]]
- } else {
- $u =~ /\A(.+)\.([0-9]+)\z/ or
- die "BUG: `$u' has no slice digit(s)";
- [ $1, $2 + 0,
- qq[* LIST (\\HasNoChildren) "." $u\r\n] ]
- }
- } keys %$mailboxes;
+ $self->{mailboxes} = $pi_cfg->{-imap_mailboxes} // do {
+ my $mailboxes = $self->{mailboxes} = {};
+ my $cache = eval { $pi_cfg->ALL->misc->nntpd_cache_load } // {};
+ my $dummies = {};
+ $pi_cfg->each_inbox(\&_refresh_ibx, $self, $cache, $dummies);
+ %$mailboxes = (%$dummies, %$mailboxes);
+ @{$pi_cfg->{-imap_mailboxlist}} = map { $_->[2] }
+ sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] }
+ map {
+ # capitalize "INBOX" for user-familiarity
+ my $u = $_;
+ $u =~ s/\Ainbox(\.|\z)/INBOX$1/i;
+ if ($mailboxes->{$_} == $dummy) {
+ [ $u, -1,
+ qq[* LIST (\\HasChildren) "." $u\r\n]]
+ } else {
+ $u =~ /\A(.+)\.([0-9]+)\z/ or die
+"BUG: `$u' has no slice digit(s)";
+ [ $1, $2 + 0, '* LIST '.
+ qq[(\\HasNoChildren) "." $u\r\n] ]
+ }
+ } keys %$mailboxes;
+ $pi_cfg->{-imap_mailboxes} = $mailboxes;
+ };
+ $self->{mailboxlist} = $pi_cfg->{-imap_mailboxlist} //
+ die 'BUG: no mailboxlist';
$self->{pi_cfg} = $pi_cfg;
if (my $idler = $self->{idler}) {
$idler->refresh($pi_cfg);
^ permalink raw reply related [relevance 7%]
* [PATCH 0/5] daemon/netd-related improvements
@ 2022-08-08 23:53 6% Eric Wong
2022-08-08 23:53 7% ` [PATCH 4/5] imap: mailboxes list across listeners Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2022-08-08 23:53 UTC (permalink / raw)
To: meta
A few minor quality-of-life improvements I've noticed while
running -netd on public-inbox.org
Eric Wong (5):
daemon: use default address + well-known ports for scheme
daemon: use per-listener SIG{__WARN__} callbacks
daemon: cleanup internal data structures
imap: mailboxes list across listeners
imapd|nntpd: drop ->base_url preload
lib/PublicInbox/Daemon.pm | 103 +++++++++++++++++++-------------------
lib/PublicInbox/HTTP.pm | 2 +-
lib/PublicInbox/HTTPD.pm | 1 +
lib/PublicInbox/IMAP.pm | 2 +-
lib/PublicInbox/IMAPD.pm | 50 +++++++++---------
lib/PublicInbox/NNTP.pm | 2 +-
lib/PublicInbox/NNTPD.pm | 1 -
lib/PublicInbox/POP3.pm | 1 +
8 files changed, 84 insertions(+), 78 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2022-08-08 23:53 6% [PATCH 0/5] daemon/netd-related improvements Eric Wong
2022-08-08 23:53 7% ` [PATCH 4/5] imap: mailboxes list across listeners Eric Wong
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).