fix: close connection on worker pool overflow

When the worker pool rejected a connection (ErrPoolOverload), the
accepted net.Conn was never closed — leaking a file descriptor and
TCP socket per rejected connection. Under sustained traffic spikes this
compounds the problem: leaked descriptors reduce the capacity for new
dials (including to the fronting domain), accelerating the failure
cascade described in #378.
This commit is contained in:
Alexey Dolotov
2026-03-28 22:52:39 +03:00
parent 836090ebdf
commit 289bb283b1
+1
View File
@@ -152,6 +152,7 @@ func (p *Proxy) Serve(listener net.Listener) error {
case errors.Is(err, ants.ErrPoolClosed): case errors.Is(err, ants.ErrPoolClosed):
return nil return nil
case errors.Is(err, ants.ErrPoolOverload): case errors.Is(err, ants.ErrPoolOverload):
conn.Close() //nolint: errcheck
logger.Info("connection was concurrency limited") logger.Info("connection was concurrency limited")
p.eventStream.Send(p.ctx, NewEventConcurrencyLimited()) p.eventStream.Send(p.ctx, NewEventConcurrencyLimited())
} }