From: Eric Wong Date: Sun, 13 Jul 2025 00:08:33 +0000 (+0000) Subject: listener: throttle errors for resource limits X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76916b4a41f4b72fa32d7d3bb93b6d83d602870f;p=thirdparty%2Fpublic-inbox.git listener: throttle errors for resource limits We don't want to flood a system and run the log partition out of space if we hit EMFILE/ENFILE/ENOMEM/ENOBUFS --- diff --git a/lib/PublicInbox/Listener.pm b/lib/PublicInbox/Listener.pm index 624756000..364301d0f 100644 --- a/lib/PublicInbox/Listener.pm +++ b/lib/PublicInbox/Listener.pm @@ -5,6 +5,7 @@ package PublicInbox::Listener; use v5.12; use parent 'PublicInbox::DS'; +use PublicInbox::DS qw(now); use Socket qw(SOL_SOCKET SO_KEEPALIVE IPPROTO_TCP TCP_NODELAY); use IO::Handle; use PublicInbox::Syscall qw(EPOLLIN EPOLLEXCLUSIVE); @@ -40,7 +41,10 @@ sub event_step { # ECONNABORTED is common with bad connections return; } elsif (my $sym = $ERR_WARN{int($!)}) { - return warn "W: accept(): $! ($sym)\n"; + my $now = now; + return if $now < ($self->{next_warn} //= 0); + $self->{next_warn} = $now + 30; + return warn "W: accept(".fileno($sock)."): $! ($sym)\n"; } else { return warn "BUG?: accept(): $!\n"; }