From 71d4c6c42f55c67821d3cf4d93ce1d904bbf2a8f Mon Sep 17 00:00:00 2001 From: 9seconds Date: Mon, 29 Mar 2021 12:12:23 +0300 Subject: [PATCH] Set worker pool to non-blocking mode --- mtglib/proxy.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mtglib/proxy.go b/mtglib/proxy.go index 6ecd236..de76a45 100644 --- a/mtglib/proxy.go +++ b/mtglib/proxy.go @@ -328,7 +328,7 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) { // nolint: cyclop, funlen ipBlocklist: opts.IPBlocklist, eventStream: opts.EventStream, logger: opts.Logger.Named("proxy"), - domainFrontingPort: int(domainFrontingPort), + domainFrontingPort: domainFrontingPort, idleTimeout: idleTimeout, bufferSize: int(bufferSize), telegram: tg, @@ -336,7 +336,9 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) { // nolint: cyclop, funlen pool, err := ants.NewPoolWithFunc(int(concurrency), func(arg interface{}) { proxy.ServeConn(arg.(net.Conn)) - }, ants.WithLogger(opts.Logger.Named("ants"))) + }, + ants.WithLogger(opts.Logger.Named("ants")), + ants.WithNonblocking(true)) if err != nil { return nil, fmt.Errorf("cannot initialize a pool: %w", err) }