]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IPC.pm
ipc: move on_destroy scope to inside the eval
[public-inbox.git] / 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;