From c5a4fb72c3b97b57a19c69fe42bca3deb6678f6f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 30 Aug 2024 19:05:15 +0000 Subject: [PATCH] lei: increase umask timeout On slow or overloaded systems, 2 seconds may not be sufficient time to wait for a lei client to respond to the umask request from lei-daemon. Use 60s to be consistent with the FD transfer in the general case. While we're at it, consistently use poll_in() now that it exists since it's a better API than vec() + select() and will give consistent performance regardless of the FD value. --- lib/PublicInbox/LEI.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 637cc8b10..6d072b95d 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -1155,8 +1155,7 @@ sub accept_dispatch { # Listener {post_accept} callback my ($sock) = @_; # ignore other $sock->autoflush(1); my $self = bless { sock => $sock }, __PACKAGE__; - vec(my $rvec = '', fileno($sock), 1) = 1; - select($rvec, undef, undef, 60) or + 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 @@ -1589,8 +1588,7 @@ sub request_umask { # assumes client is trusted and fast my ($v, $r, $u); do { # n.b. poll_in returns -1 on EINTR vec($v = '', fileno($s), 1) = 1; - $r = poll_in($s, 2) or - die 'timeout waiting for umask'; + $r = poll_in $s, 60_000 or die 'timeout waiting for umask'; } while ($r < 0 && $! == EINTR); do { $r = recv $s, $v, 5, 0; -- 2.47.2