From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 19CC92007E for ; Mon, 1 Feb 2021 08:28:35 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 13/21] lei: increase initial timeout Date: Sun, 31 Jan 2021 22:28:25 -1000 Message-Id: <20210201082833.3293-14-e@80x24.org> In-Reply-To: <20210201082833.3293-1-e@80x24.org> References: <20210201082833.3293-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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);