Otherwise the old watcher may run indefinitely
$im->add($mime, $self->{spamcheck});
}
+sub quit { $_[0]->{quit} = 1 }
+
sub watch {
my ($self) = @_;
my $cb = sub { _try_fsn_paths($self, \@_) };
# in the future...
require Filesys::Notify::Simple;
my $watcher = Filesys::Notify::Simple->new($mdir);
- $watcher->wait($cb) while (1);
+ $watcher->wait($cb) until ($self->{quit});
}
sub scan {
my ($config, $watch_md);
my $reload = sub {
$config = PublicInbox::Config->new;
+ $watch_md->quit if $watch_md;
$watch_md = PublicInbox::WatchMaildir->new($config);
};
$reload->();
$SIG{USR1} = $scan;
$SIG{ALRM} = sub { $SIG{ALRM} = 'DEFAULT'; $scan->() };
alarm(1);
- $watch_md->watch;
+ $watch_md->watch while ($watch_md);
}