From: Eric Wong Date: Tue, 29 Apr 2025 17:16:48 +0000 (+0000) Subject: lei: deal with spurious wakeups X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9bd92a120652b74ea483b37839ef08ce426b4e8;p=thirdparty%2Fpublic-inbox.git lei: deal with spurious wakeups Apparently spurious wakeups remain a problem even for local sockets. Oddly, I only noticed this when switching lei to use epoll_pwait on a slow machine. --- diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index afe78e07f..3e205f5c7 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -1157,11 +1157,14 @@ sub accept_dispatch { # Listener {post_accept} callback my ($sock) = @_; # ignore other $sock->autoflush(1); my $self = bless { sock => $sock }, __PACKAGE__; - poll_in $sock, 60_000 or - return send_gently $sock, 'timed out waiting to recv FDs'; - # (4096 * 33) >MAX_ARG_STRLEN - my @fds = $PublicInbox::IPC::recv_cmd->($sock, my $buf, 4096 * 33) or - return; # EOF + my (@fds, $buf); + do { + poll_in $sock, 60_000 or return send_gently $sock, + 'timed out waiting to recv FDs'; + # (4096 * 33) >MAX_ARG_STRLEN + @fds = $PublicInbox::IPC::recv_cmd->($sock, $buf, 4096 * 33) + or return; # EOF + } while (!defined($fds[0]) && $! == EAGAIN); if (!defined($fds[0])) { warn(my $msg = "recv_cmd failed: $!"); return send_gently $sock, $msg;