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-ASN: 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 A640A1F8C8 for ; Wed, 28 Jul 2021 00:37:19 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] listener: maximize listen(2) backlog Date: Wed, 28 Jul 2021 00:37:19 +0000 Message-Id: <20210728003719.24083-3-e@80x24.org> In-Reply-To: <20210728003719.24083-1-e@80x24.org> References: <20210728003719.24083-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This helps avoid errors from script/lei dying on ECONNRESET when a single lei-daemon is serving all tests when run via "make check-run". Instead of using some arbitrary limit, use INT_MAX and let the kernel clamp it (both Linux and FreeBSD do). There's no need to call listen() in LEI.pm, either, since Listener->new takes care of it. --- lib/PublicInbox/LEI.pm | 1 - lib/PublicInbox/Listener.pm | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 191a0790..38b268d3 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -1205,7 +1205,6 @@ sub lazy_start { } umask(077) // die("umask(077): $!"); bind($listener, $addr) or die "bind($path): $!"; - listen($listener, 1024) or die "listen: $!"; $lk->lock_release; undef $lk; my @st = stat($path) or die "stat($path): $!"; diff --git a/lib/PublicInbox/Listener.pm b/lib/PublicInbox/Listener.pm index c8315810..64bba5b0 100644 --- a/lib/PublicInbox/Listener.pm +++ b/lib/PublicInbox/Listener.pm @@ -20,7 +20,7 @@ sub new ($$$) { my ($class, $s, $cb) = @_; setsockopt($s, SOL_SOCKET, SO_KEEPALIVE, 1); setsockopt($s, IPPROTO_TCP, TCP_NODELAY, 1); # ignore errors on non-TCP - listen($s, 1024); + listen($s, 2**31 - 1); # kernel will clamp my $self = bless { post_accept => $cb }, $class; $self->SUPER::new($s, EPOLLIN|EPOLLET|EPOLLEXCLUSIVE); }