]> Sergey Matveev's repositories - public-inbox.git/commitdiff
ipc: move on_destroy scope to inside the eval
authorEric Wong <e@80x24.org>
Fri, 29 Jan 2021 07:42:59 +0000 (12:42 +0500)
committerEric Wong <e@80x24.org>
Sat, 30 Jan 2021 01:08:21 +0000 (01:08 +0000)
It saves us a line of code

lib/PublicInbox/IPC.pm

index ece0e8b809798b5571711624875a746b2b452fc9..d2ff038dc77463fa363af385dc5eccef1183a27b 100644 (file)
@@ -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;