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=-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 1DB361FA19 for ; Fri, 29 Jan 2021 07:43:01 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 6/7] ipc: move on_destroy scope to inside the eval Date: Fri, 29 Jan 2021 12:42:59 +0500 Message-Id: <20210129074300.14475-7-e@80x24.org> In-Reply-To: <20210129074300.14475-1-e@80x24.org> References: <20210129074300.14475-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It saves us a line of code --- lib/PublicInbox/IPC.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm index ece0e8b8..d2ff038d 100644 --- a/lib/PublicInbox/IPC.pm +++ b/lib/PublicInbox/IPC.pm @@ -119,13 +119,12 @@ sub ipc_worker_spawn { PublicInbox::DS::sig_setmask($sigset); # ensure we properly exit even if warn() dies: my $end = PublicInbox::OnDestroy->new($$, sub { exit(!!$@) }); - my $on_destroy = $self->ipc_atfork_child; eval { + my $on_destroy = $self->ipc_atfork_child; local %SIG = %SIG; ipc_worker_loop($self, $r_req, $w_res); }; die "worker $ident PID:$$ died: $@\n" if $@; - undef $on_destroy; undef $end; # trigger exit } PublicInbox::DS::sig_setmask($sigset) unless $oldset; @@ -336,13 +335,12 @@ sub _wq_worker_start ($$$) { PublicInbox::DS::sig_setmask($oldset); # ensure we properly exit even if warn() dies: my $end = PublicInbox::OnDestroy->new($$, sub { exit(!!$@) }); - my $on_destroy = $self->ipc_atfork_child; eval { + my $on_destroy = $self->ipc_atfork_child; local %SIG = %SIG; wq_worker_loop($self); }; warn "worker $self->{-wq_ident} PID:$$ died: $@" if $@; - undef $on_destroy; undef $end; # trigger exit } else { $self->{-wq_workers}->{$pid} = \undef;