mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 11:04:02 +03:00
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:
@@ -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())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user