]> Sergey Matveev's repositories - public-inbox.git/commitdiff
ipc: avoid excessive evals
authorEric Wong <e@80x24.org>
Sun, 10 Jan 2021 12:15:03 +0000 (12:15 +0000)
committerEric Wong <e@80x24.org>
Tue, 12 Jan 2021 03:51:42 +0000 (03:51 +0000)
We should not need an eval for warning with our code base.
Nowadays, dwaitpid() automatically does the right thing
regardless of whether we're in the event loop, so no eval
is needed there, either.

lib/PublicInbox/IPC.pm

index 7dc8ec6a9860f20d95205dd40e9a9266737b729b..5082f1103f3f93924b1a0a34fd1294c8c0b16ddd 100644 (file)
@@ -69,7 +69,7 @@ sub ipc_worker_loop ($$$) {
                # this is the overwhelmingly likely case
                if (!defined($wantarray)) {
                        eval { $self->$sub(@args) };
-                       eval { warn "$$ die: $@ (from nowait $sub)\n" } if $@;
+                       warn "$$ die: $@ (from nowait $sub)\n" if $@;
                } elsif ($wantarray) {
                        my @ret = eval { $self->$sub(@args) };
                        ipc_return($w_res, \@ret, $@);
@@ -144,15 +144,7 @@ sub ipc_worker_stop {
 
        # allow any sibling to send ipc_worker_exit, but siblings can't wait
        return if $$ != $ppid;
-       eval {
-               my $reap = $self->can('ipc_worker_reap');
-               PublicInbox::DS::dwaitpid($pid, $reap, $self);
-       };
-       if ($@) {
-               my $wp = waitpid($pid, 0);
-               $pid == $wp or die "waitpid($pid) returned $wp: \$?=$?";
-               $self->ipc_worker_reap($pid);
-       }
+       PublicInbox::DS::dwaitpid($pid, \&ipc_worker_reap, $self);
 }
 
 # use this if we have multiple readers reading curl or "pigz -dc"