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-Status: No, score=-3.9 required=3.0 tests=ALL_TRUSTED,AWL,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 EF7761F8C8 for ; Sat, 6 Feb 2021 12:18:44 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/17] lei: abort lei_import worker on client abort Date: Sat, 6 Feb 2021 12:18:31 +0000 Message-Id: <20210206121844.10979-5-e@80x24.org> In-Reply-To: <20210206121844.10979-1-e@80x24.org> References: <20210206121844.10979-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We'll stuff all the common wq key fields into the @WQ_KEYS array so it's easier to keep track of what to kill or reap. --- lib/PublicInbox/LEI.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 8d5a921e..28ad88e7 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -286,6 +286,8 @@ my %CONFIG_KEYS = ( 'leistore.dir' => 'top-level storage location', ); +my @WQ_KEYS = qw(lxs l2m imp); # internal workers + # pronounced "exit": x_it(1 << 8) => exit(1); x_it(13) => SIGPIPE sub x_it ($$) { my ($self, $code) = @_; @@ -296,7 +298,7 @@ sub x_it ($$) { send($s, "x_it $code", MSG_EOR); } elsif ($self->{oneshot}) { # don't want to end up using $? from child processes - for my $f (qw(lxs l2m)) { + for my $f (@WQ_KEYS) { my $wq = delete $self->{$f} or next; $wq->DESTROY; } @@ -327,7 +329,7 @@ sub qerr ($;@) { $_[0]->{opt}->{quiet} or err(shift, @_) } sub fail_handler ($;$$) { my ($lei, $code, $io) = @_; - for my $f (qw(imp lxs l2m)) { + for my $f (@WQ_KEYS) { my $wq = delete $lei->{$f} or next; $wq->wq_wait_old($lei) if $wq->wq_kill_old; # lei-daemon } @@ -335,7 +337,7 @@ sub fail_handler ($;$$) { $lei->x_it($code // (1 >> 8)); } -sub sigpipe_handler { # handles SIGPIPE from l2m/lxs workers +sub sigpipe_handler { # handles SIGPIPE from @WQ_KEYS workers fail_handler($_[0], 13, delete $_[0]->{1}); } @@ -856,7 +858,7 @@ sub accept_dispatch { # Listener {post_accept} callback sub dclose { my ($self) = @_; delete $self->{-progress}; - for my $f (qw(lxs l2m)) { + for my $f (@WQ_KEYS) { my $wq = delete $self->{$f} or next; if ($wq->wq_kill) { $wq->wq_close