]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei: deal with spurious wakeups
authorEric Wong <e@80x24.org>
Tue, 29 Apr 2025 17:16:48 +0000 (17:16 +0000)
committerEric Wong <e@80x24.org>
Thu, 1 May 2025 21:29:44 +0000 (21:29 +0000)
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.

lib/PublicInbox/LEI.pm

index afe78e07f5820c0a08bc45a8bad118268a391d6e..3e205f5c7e0ac3d7919143fb707a33c561dfe090 100644 (file)
@@ -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;