From 76916b4a41f4b72fa32d7d3bb93b6d83d602870f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 13 Jul 2025 00:08:33 +0000 Subject: [PATCH] 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 --- lib/PublicInbox/Listener.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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"; } -- 2.47.2