From 8c7e3c3ee6fa5ba6b9414b5d4f57117dcf86ed2d Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 20 May 2026 08:19:46 -0400 Subject: [PATCH] fix RunDialer: drain dial signals only after successful connect --- outbound/worker.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/outbound/worker.go b/outbound/worker.go index 8a01352..560e187 100644 --- a/outbound/worker.go +++ b/outbound/worker.go @@ -532,24 +532,11 @@ func RunDialer( case <-ctx.Done(): return case <-dial: - // drain dial signals while connection is being established - done := make(chan struct{}) - go func() { - for { - select { - case <-dial: - case <-done: - return - } - } - }() - if logger != nil { logger.Debug("dialer: dialing") } // dial a new connection conn, err := connect(id, ctx, pool) - close(done) // send error if dial failed and continue if err != nil { @@ -563,6 +550,16 @@ func RunDialer( logger.Debug("dialer: connected") } + // drain any redundant signals that arrived during the dial + for { + select { + case <-dial: + default: + goto drained + } + } + drained: + // send the new connection or close and exit select { case newConn <- conn: