about summary refs log tree commit homepage
path: root/lib/PublicInbox/IMAPD.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:04 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commit9d154055ec44903052beaa4e2c1221f39d6d507a (patch)
treeb76b693d85976839bbedba525a38f99a85760dd1 /lib/PublicInbox/IMAPD.pm
parenteab4dfdda4eeea9a54aa674510fa11789c5f91c8 (diff)
downloadpublic-inbox-9d154055ec44903052beaa4e2c1221f39d6d507a.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/IMAPD.pm')
-rw-r--r--lib/PublicInbox/IMAPD.pm14
1 files changed, 9 insertions, 5 deletions
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;