mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-18 12:39:54 +00:00
[relay] Count winning attempt before draining losers
The success path in handleResult left settled at 0, so drainLoser waited on a result that was already consumed and blocked forever, leaking a goroutine and the results channel on every successful race. Increment settled before stop() so drainLoser only waits for actual started losers.
This commit is contained in:
@@ -107,6 +107,7 @@ func (c *connRace) startOther() {
|
||||
|
||||
func (c *connRace) handleResult(res raceAttempt) raceOutcome {
|
||||
if (res.err == nil && res.conn != nil) || errors.Is(res.err, ErrConnAlreadyExists) {
|
||||
c.settled++
|
||||
c.stop()
|
||||
return raceOutcome{conn: res.conn, err: res.err, done: true}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user