From 1bedfa32517d76422f25019f26067fdaf3d15367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 15 Dec 2024 02:38:55 +0800 Subject: [PATCH] Add debug info --- common/dialer/default_parallel_interface.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/common/dialer/default_parallel_interface.go b/common/dialer/default_parallel_interface.go index 44cd3b05ad..ffd606e92f 100644 --- a/common/dialer/default_parallel_interface.go +++ b/common/dialer/default_parallel_interface.go @@ -36,12 +36,16 @@ func (d *DefaultDialer) dialParallelInterface(ctx context.Context, dialer net.Di if err != nil { select { case results <- dialResult{error: E.Cause(err, "dial ", iif.Name, " (", iif.Name, ")"), primary: primary}: + println("reterr", primary) case <-returned: + println("retnil", primary) } } else { select { - case results <- dialResult{Conn: conn}: + case results <- dialResult{Conn: conn, primary: primary}: + println("retconn", primary) case <-returned: + println("retclose", primary) conn.Close() } } @@ -64,6 +68,7 @@ func (d *DefaultDialer) dialParallelInterface(ctx context.Context, dialer net.Di for { select { case <-fallbackChan: + println("start fallback") fallbackCtx, fallbackCancel := context.WithCancel(ctx) defer fallbackCancel() for _, iif := range fallbackInterfaces { @@ -71,8 +76,10 @@ func (d *DefaultDialer) dialParallelInterface(ctx context.Context, dialer net.Di } case res := <-results: if res.error == nil { + println("return", res.primary) return res.Conn, res.primary, nil } + println("err", res.primary) errors = append(errors, res.error) if len(errors) == len(primaryInterfaces)+len(fallbackInterfaces) { return nil, false, E.Errors(errors...) @@ -108,16 +115,20 @@ func (d *DefaultDialer) dialParallelInterfaceFastFallback(ctx context.Context, d if err != nil { select { case results <- dialResult{error: E.Cause(err, "dial ", iif.Name, " (", iif.Name, ")"), primary: primary}: + println("freterr", primary) case <-returned: + println("fretnil", primary) } } else { select { - case results <- dialResult{Conn: conn}: + case results <- dialResult{Conn: conn, primary: primary}: + println("fretconn", primary) case <-returned: if primary && time.Since(startAt) <= fallbackDelay { resetFastFallback(time.Time{}) } conn.Close() + println("fretclose", primary) } } } @@ -134,8 +145,10 @@ func (d *DefaultDialer) dialParallelInterfaceFastFallback(ctx context.Context, d select { case res := <-results: if res.error == nil { + println("freturn", res.primary) return res.Conn, res.primary, nil } + println("ferr", res.primary) errors = append(errors, res.error) if len(errors) == len(primaryInterfaces)+len(fallbackInterfaces) { return nil, false, E.Errors(errors...)