From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DDA1C1FA18 for ; Fri, 30 Apr 2021 09:24:38 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/8] lei: kill old PIDs when dropping Date: Fri, 30 Apr 2021 09:24:33 +0000 Message-Id: <20210430092438.20926-4-e@80x24.org> In-Reply-To: <20210430092438.20926-1-e@80x24.org> References: <20210430092438.20926-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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