From b436cf6e4794a32b3331a8727d10bf000ba55de2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 31 Jan 2021 22:28:25 -1000 Subject: [PATCH 1/1] lei: increase initial timeout PublicInbox::Listener unconditionally sets O_NONBLOCK upon accept(), so we need a larger timeout under heavy load since there's no "dataready" accept filter on the listener. With O_NONBLOCK already set, we don't have to set it at ->event_step_init --- lib/PublicInbox/LEI.pm | 7 ++++--- script/lei | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 08554932..e2f22a75 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -824,7 +824,7 @@ sub accept_dispatch { # Listener {post_accept} callback $sock->autoflush(1); my $self = bless { sock => $sock }, __PACKAGE__; vec(my $rvec = '', fileno($sock), 1) = 1; - select($rvec, undef, undef, 1) or + select($rvec, undef, undef, 60) or return send($sock, 'timed out waiting to recv FDs', MSG_EOR); my @fds = $recv_cmd->($sock, my $buf, 4096 * 33); # >MAX_ARG_STRLEN if (scalar(@fds) == 4) { @@ -834,7 +834,9 @@ sub accept_dispatch { # Listener {post_accept} callback send($sock, "open(+<&=$fd) (FD=$i): $!", MSG_EOR); } } else { - return send($sock, "recv_cmd failed: $!", MSG_EOR); + my $msg = "recv_cmd failed: $!"; + warn $msg; + return send($sock, $msg, MSG_EOR); } $self->{2}->autoflush(1); # keep stdout buffered until x_it|DESTROY # $ENV_STR = join('', map { "\0$_=$ENV{$_}" } keys %ENV); @@ -898,7 +900,6 @@ sub event_step { sub event_step_init { my ($self) = @_; if (my $sock = $self->{sock}) { # using DS->EventLoop - $sock->blocking(0); $self->SUPER::new($sock, EPOLLIN|EPOLLET); } } diff --git a/script/lei b/script/lei index 006c1180..f92dd302 100755 --- a/script/lei +++ b/script/lei @@ -79,7 +79,8 @@ Falling back to (slow) one-shot mode my $buf = join("\0", scalar(@ARGV), @ARGV); while (my ($k, $v) = each %ENV) { $buf .= "\0$k=$v" } $buf .= "\0\0"; - $send_cmd->($sock, [ 0, 1, 2, fileno($dh) ], $buf, MSG_EOR); + $send_cmd->($sock, [ 0, 1, 2, fileno($dh) ], $buf, MSG_EOR) or + die "sendmsg: $!"; my $x_it_code = 0; while (1) { my (@fds) = $recv_cmd->($sock, $buf, 4096 * 33); -- 2.44.0