diff options
author | Eric Wong <e@80x24.org> | 2024-04-25 21:31:44 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2024-04-28 17:05:28 +0000 |
commit | 25c5108f2bdb29009ac986b7bde29ffca24e6e7a (patch) | |
tree | caafc84388fe38a282e5d0f5dc87c9612a1fa178 /lib/PublicInbox/CmdIPC4.pm | |
parent | dba2370bd52ce5b550906c7fdb516af512d81bce (diff) | |
download | public-inbox-25c5108f2bdb29009ac986b7bde29ffca24e6e7a.tar.gz |
While existing callers are private (lei, *-index, -watch) are private, we should not be blocking the event loop in public-facing servers when we hit ETOOMANYREFS, ENOMEM, or ENOBUFS.
Diffstat (limited to 'lib/PublicInbox/CmdIPC4.pm')
-rw-r--r-- | lib/PublicInbox/CmdIPC4.pm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/PublicInbox/CmdIPC4.pm b/lib/PublicInbox/CmdIPC4.pm index 2f102ec6..fc77bd03 100644 --- a/lib/PublicInbox/CmdIPC4.pm +++ b/lib/PublicInbox/CmdIPC4.pm @@ -11,8 +11,8 @@ use Socket qw(SOL_SOCKET SCM_RIGHTS); sub sendmsg_retry ($) { return 1 if $!{EINTR}; return unless ($!{ENOMEM} || $!{ENOBUFS} || $!{ETOOMANYREFS}); - return if ++$_[0] >= 50; - warn "# sleeping on sendmsg: $! (#$_[0])\n"; + return if --$_[0] < 0; + warn "# sleeping on sendmsg: $! ($_[0] tries left)\n"; select(undef, undef, undef, 0.1); 1; } @@ -22,15 +22,15 @@ require Socket::MsgHdr; # XS no warnings 'once'; # any number of FDs per-sendmsg(2) + buffer -*send_cmd4 = sub ($$$$) { # (sock, fds, buf, flags) = @_; - my ($sock, $fds, undef, $flags) = @_; +*send_cmd4 = sub ($$$$;$) { # (sock, fds, buf, flags) = @_; + my ($sock, $fds, undef, $flags, $tries) = @_; + $tries //= 50; my $mh = Socket::MsgHdr->new(buf => $_[2]); $mh->cmsghdr(SOL_SOCKET, SCM_RIGHTS, pack('i' x scalar(@$fds), @$fds)); my $s; - my $try = 0; do { $s = Socket::MsgHdr::sendmsg($sock, $mh, $flags); - } while (!defined($s) && sendmsg_retry($try)); + } while (!defined($s) && sendmsg_retry($tries)); $s; }; |