From 8bb96e2da15ce323024be8de8b89bc386ee33339 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 30 Apr 2021 09:24:33 +0000 Subject: lei: kill old PIDs when dropping 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 52ce8ec2..3468094f 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -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 -- cgit v1.2.3-24-ge0c7