From 9d154055ec44903052beaa4e2c1221f39d6d507a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 10 Jun 2020 07:04:04 +0000 Subject: imap: delay InboxIdle start, support refresh InboxIdle should not be holding onto Inbox objects after the Config object they came from expires, and Config objects may expire on SIGHUP. Old Inbox objects still persist due to IMAP clients holding onto them, but that's a concern we'll deal with at another time, or not at all, since all clients expire, eventually. Regardless, stale inotify watch descriptors should not be left hanging after SIGHUP refreshes. --- lib/PublicInbox/IMAPD.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/PublicInbox/IMAPD.pm') diff --git a/lib/PublicInbox/IMAPD.pm b/lib/PublicInbox/IMAPD.pm index 1922c160..05aa30e4 100644 --- a/lib/PublicInbox/IMAPD.pm +++ b/lib/PublicInbox/IMAPD.pm @@ -16,18 +16,22 @@ sub new { out => \*STDOUT, grouplist => [], # accept_tls => { SSL_server => 1, ..., SSL_reuse_ctx => ... } + # pi_config => PublicInbox::Config # idler => PublicInbox::InboxIdle }, $class; } sub refresh_groups { my ($self) = @_; - if (my $old_idler = delete $self->{idler}) { - $old_idler->close; # PublicInbox::DS::close - } - my $pi_config = PublicInbox::Config->new; - $self->{idler} = PublicInbox::InboxIdle->new($pi_config); + my $pi_config = $self->{pi_config} = PublicInbox::Config->new; $self->SUPER::refresh_groups($pi_config); + if (my $idler = $self->{idler}) { + $idler->refresh($pi_config); + } +} + +sub idler_start { + $_[0]->{idler} //= PublicInbox::InboxIdle->new($_[0]->{pi_config}); } 1; -- cgit v1.2.3-24-ge0c7