Преглед изворни кода

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.
tags/v2.2.5^2^2
Alexey Dolotov пре 1 месец
родитељ
комит
289bb283b1
1 измењених фајлова са 1 додато и 0 уклоњено
  1. 1
    0
      mtglib/proxy.go

+ 1
- 0
mtglib/proxy.go Прегледај датотеку

152
 		case errors.Is(err, ants.ErrPoolClosed):
152
 		case errors.Is(err, ants.ErrPoolClosed):
153
 			return nil
153
 			return nil
154
 		case errors.Is(err, ants.ErrPoolOverload):
154
 		case errors.Is(err, ants.ErrPoolOverload):
155
+			conn.Close() //nolint: errcheck
155
 			logger.Info("connection was concurrency limited")
156
 			logger.Info("connection was concurrency limited")
156
 			p.eventStream.Send(p.ctx, NewEventConcurrencyLimited())
157
 			p.eventStream.Send(p.ctx, NewEventConcurrencyLimited())
157
 		}
158
 		}

Loading…
Откажи
Сачувај