]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Watch.pm
watch: check for {quit} before IDLE
[public-inbox.git] / lib / PublicInbox / Watch.pm
index 0523ad03f8710257e60957d6ddddb23b7943689f..e80bbdec16fdf8dd766b8761d059caf48891e373 100644 (file)
@@ -12,7 +12,6 @@ use PublicInbox::MdirReader;
 use PublicInbox::NetReader;
 use PublicInbox::Filter::Base qw(REJECT);
 use PublicInbox::Spamcheck;
-use PublicInbox::Sigfd;
 use PublicInbox::DS qw(now add_timer);
 use PublicInbox::MID qw(mids);
 use PublicInbox::ContentHash qw(content_hash);
@@ -283,7 +282,8 @@ sub watch_fs_init ($) {
        };
        require PublicInbox::DirIdle;
        # inotify_create + EPOLL_CTL_ADD
-       PublicInbox::DirIdle->new([keys %{$self->{mdmap}}], $cb);
+       my $dir_idle = PublicInbox::DirIdle->new($cb);
+       $dir_idle->add_watches([keys %{$self->{mdmap}}]);
 }
 
 sub net_cb { # NetReader::(nntp|imap)_each callback
@@ -330,6 +330,7 @@ sub imap_idle_once ($$$$) {
        my $end = now() + $intvl;
        warn "I: $uri idling for ${intvl}s\n";
        local $0 = "IDLE $0";
+       return if $self->{quit};
        unless ($mic->idle) {
                return if $self->{quit};
                return "E: IDLE failed on $uri: $!";
@@ -570,7 +571,7 @@ sub watch { # main entry point
        }
        watch_fs_init($self) if $self->{mdre};
        PublicInbox::DS->SetPostLoopCallback(sub { !$self->quit_done });
-       PublicInbox::DS->EventLoop; # calls ->event_step
+       PublicInbox::DS::event_loop($sig, $oldset); # calls ->event_step
        _done_for_now($self);
 }