Set worker pool to non-blocking mode

This commit is contained in:
9seconds
2021-03-29 12:12:23 +03:00
parent 75b05b9b14
commit 71d4c6c42f
+4 -2
View File
@@ -328,7 +328,7 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) { // nolint: cyclop, funlen
ipBlocklist: opts.IPBlocklist, ipBlocklist: opts.IPBlocklist,
eventStream: opts.EventStream, eventStream: opts.EventStream,
logger: opts.Logger.Named("proxy"), logger: opts.Logger.Named("proxy"),
domainFrontingPort: int(domainFrontingPort), domainFrontingPort: domainFrontingPort,
idleTimeout: idleTimeout, idleTimeout: idleTimeout,
bufferSize: int(bufferSize), bufferSize: int(bufferSize),
telegram: tg, telegram: tg,
@@ -336,7 +336,9 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) { // nolint: cyclop, funlen
pool, err := ants.NewPoolWithFunc(int(concurrency), func(arg interface{}) { pool, err := ants.NewPoolWithFunc(int(concurrency), func(arg interface{}) {
proxy.ServeConn(arg.(net.Conn)) proxy.ServeConn(arg.(net.Conn))
}, ants.WithLogger(opts.Logger.Named("ants"))) },
ants.WithLogger(opts.Logger.Named("ants")),
ants.WithNonblocking(true))
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot initialize a pool: %w", err) return nil, fmt.Errorf("cannot initialize a pool: %w", err)
} }