]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: increase initial timeout
authorEric Wong <e@80x24.org>
Mon, 1 Feb 2021 08:28:25 +0000 (22:28 -1000)
committerEric Wong <e@80x24.org>
Mon, 1 Feb 2021 11:38:18 +0000 (11:38 +0000)
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
script/lei

index 08554932ab8b06957c81380feb9aee1ad6c18192..e2f22a7564a4366e46a65a3a0af82833b57f5785 100644 (file)
@@ -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);
        }
 }
index 006c118089397ff9e670e1de52b56c6e0a59f0ee..f92dd302525fca9eb41b93ee580264c588e659c6 100755 (executable)
@@ -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);