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 019481FA19 for ; Sun, 10 Jan 2021 12:15:20 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 06/22] ipc: avoid excessive evals Date: Sun, 10 Jan 2021 12:15:03 +0000 Message-Id: <20210110121519.17044-7-e@80x24.org> In-Reply-To: <20210110121519.17044-1-e@80x24.org> References: <20210110121519.17044-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm index 7dc8ec6a..5082f110 100644 --- a/lib/PublicInbox/IPC.pm +++ b/lib/PublicInbox/IPC.pm @@ -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"