]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: kill old PIDs when dropping
authorEric Wong <e@80x24.org>
Fri, 30 Apr 2021 09:24:33 +0000 (09:24 +0000)
committerEric Wong <e@80x24.org>
Fri, 30 Apr 2021 19:59:44 +0000 (19:59 +0000)
This ensures hitting Ctrl-C on a long-running "lei convert" or
similar will stop the WQ worker, even after we've closed
the WQ socketpair in the daemon.

lib/PublicInbox/LEI.pm

index 52ce8ec272e74e68d3ba7b5beabb566240d01066..3468094f53c4c3dda67f06f63c1a8ebf16de4efe 100644 (file)
@@ -387,7 +387,14 @@ my @WQ_KEYS = qw(lxs l2m wq1); # internal workers
 
 sub _drop_wq {
        my ($self) = @_;
-       for my $wq (grep(defined, delete(@$self{@WQ_KEYS}))) { $wq->DESTROY }
+       for my $wq (grep(defined, delete(@$self{@WQ_KEYS}))) {
+               if ($wq->wq_kill) {
+                       $wq->wq_close(0, undef, $self);
+               } elsif ($wq->wq_kill_old) {
+                       $wq->wq_wait_old(undef, $self);
+               }
+               $wq->DESTROY;
+       }
 }
 
 # pronounced "exit": x_it(1 << 8) => exit(1); x_it(13) => SIGPIPE