* [PATCH 1/6] ds: awaitpid: Perl waitpid retries on EINTR automatically
2023-09-26 7:44 6% [PATCH 0/6] waitpid-related cleanups Eric Wong
@ 2023-09-26 7:44 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-09-26 7:44 UTC (permalink / raw)
To: meta
perlipc(1) man page states both wait + waitpid will retry
on EINTR. Thus there's no need to retry it ourselves.
---
lib/PublicInbox/DS.pm | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 49550b2b..142122a8 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -32,7 +32,7 @@ use PublicInbox::Syscall qw(%SIGNUM
EPOLLIN EPOLLOUT EPOLLONESHOT EPOLLEXCLUSIVE);
use PublicInbox::Tmpfile;
use PublicInbox::Select;
-use Errno qw(EAGAIN EINVAL ECHILD EINTR);
+use Errno qw(EAGAIN EINVAL ECHILD);
use Carp qw(carp croak);
our @EXPORT_OK = qw(now msg_more awaitpid add_timer add_uniq_timer);
@@ -713,16 +713,13 @@ sub awaitpid {
$AWAIT_PIDS->{$pid} = \@cb_args if @cb_args;
# provide synchronous API
if (defined(wantarray) || (!$in_loop && !@cb_args)) {
- my $ret;
-again:
- $ret = waitpid($pid, 0) // -2;
+ my $ret = waitpid($pid, 0);
if ($ret == $pid) {
my $cb_args = delete $AWAIT_PIDS->{$pid};
@cb_args = @$cb_args if !@cb_args && $cb_args;
await_cb($pid, @cb_args);
} else {
- goto again if $! == EINTR;
- carp "waitpid($pid): $!";
+ carp "waitpid($pid) => $ret ($!)";
delete $AWAIT_PIDS->{$pid};
}
return $ret;
^ permalink raw reply related [relevance 7%]
* [PATCH 0/6] waitpid-related cleanups
@ 2023-09-26 7:44 6% Eric Wong
2023-09-26 7:44 7% ` [PATCH 1/6] ds: awaitpid: Perl waitpid retries on EINTR automatically Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-09-26 7:44 UTC (permalink / raw)
To: meta
Mainly, much of our code was too noisy and guarding for waitpid
error cases which never happen.
Perl `waitpid' will always retry on EINTR (cf. perlipc(1)) and
it never returns `undef' on error, only -1. I don't understand
why Perl does it this way, all other syscalls return `undef' on
error, but Perl only documents -1 for errors and my
understanding of the Perl sources says it can't return `undef'.
So start working on reducing waitpid call sites...
Eric Wong (6):
ds: awaitpid: Perl waitpid retries on EINTR automatically
auto_reap: waitpid never returns undef
lei_blob: use ProcessPipe to eliminate a waitpid call
fetch: fix missing chdir arg for error reporting
spamcheck/spamc: rely on ProcessPipe instead of waitpid
spawn: add run_wait to simplify spawn+waitpid use
lib/PublicInbox/AutoReap.pm | 7 +++----
lib/PublicInbox/DS.pm | 9 +++------
lib/PublicInbox/Fetch.pm | 10 +++++-----
lib/PublicInbox/LEI.pm | 5 ++---
lib/PublicInbox/LeiBlob.pm | 19 +++++++------------
lib/PublicInbox/LeiMailDiff.pm | 6 ++----
lib/PublicInbox/LeiMirror.pm | 8 +++-----
lib/PublicInbox/LeiRediff.pm | 7 +++----
lib/PublicInbox/SearchIdx.pm | 6 ++----
lib/PublicInbox/Spamcheck/Spamc.pm | 11 ++++-------
lib/PublicInbox/Spawn.pm | 13 +++++++++----
lib/PublicInbox/TestCommon.pm | 6 +-----
12 files changed, 44 insertions(+), 63 deletions(-)
More deletions than insertions is good.
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-09-26 7:44 6% [PATCH 0/6] waitpid-related cleanups Eric Wong
2023-09-26 7:44 7% ` [PATCH 1/6] ds: awaitpid: Perl waitpid retries on EINTR automatically Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).