refactor(tcpfwd): заменить busy-loop poll пула на Ready-канал; тихий accept-цикл при shutdown

This commit is contained in:
samosvalishe committed 2026-05-20 11:49:21 +03:00
1 parent 1459f39551
commit 2b24471553
2 files changed
+25 -13

No files matched your search

+6 -13
View File
@@ -70,16 +70,11 @@ func Run(ctx context.Context, deps *Deps, params *Params, peer *net.UDPAddr, lis
}
deps.log().Infof("VLESS mode: waiting for sessions to connect (total: %d)...", numSessions)
for {
select {
case <-ctx.Done():
wgMaint.Wait()
return nil
case <-time.After(100 * time.Millisecond):
}
if pool.Count() > 0 {
break
}
select {
case <-ctx.Done():
wgMaint.Wait()
return nil
case <-pool.Ready():
}
listener, err := net.Listen("tcp", listenAddr)
@@ -105,12 +100,10 @@ func Run(ctx context.Context, deps *Deps, params *Params, peer *net.UDPAddr, lis
for {
tcpConn, err := wrappedListener.Accept()
if err != nil {
select {
case <-ctx.Done():
if ctx.Err() != nil {
wgConn.Wait()
wgMaint.Wait()
return nil
default:
}
deps.log().Errorf("TCP accept error: %s", err)
continue