瀏覽代碼

Set worker pool to non-blocking mode

tags/v2.0.0-rc1
9seconds 5 年之前
父節點
當前提交
71d4c6c42f
共有 1 個檔案被更改,包括 4 行新增2 行删除
  1. 4
    2
      mtglib/proxy.go

+ 4
- 2
mtglib/proxy.go 查看文件

@@ -328,7 +328,7 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) { // nolint: cyclop, funlen
328 328
 		ipBlocklist:        opts.IPBlocklist,
329 329
 		eventStream:        opts.EventStream,
330 330
 		logger:             opts.Logger.Named("proxy"),
331
-		domainFrontingPort: int(domainFrontingPort),
331
+		domainFrontingPort: domainFrontingPort,
332 332
 		idleTimeout:        idleTimeout,
333 333
 		bufferSize:         int(bufferSize),
334 334
 		telegram:           tg,
@@ -336,7 +336,9 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) { // nolint: cyclop, funlen
336 336
 
337 337
 	pool, err := ants.NewPoolWithFunc(int(concurrency), func(arg interface{}) {
338 338
 		proxy.ServeConn(arg.(net.Conn))
339
-	}, ants.WithLogger(opts.Logger.Named("ants")))
339
+	},
340
+		ants.WithLogger(opts.Logger.Named("ants")),
341
+		ants.WithNonblocking(true))
340 342
 	if err != nil {
341 343
 		return nil, fmt.Errorf("cannot initialize a pool: %w", err)
342 344
 	}

Loading…
取消
儲存