[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:
Zoltan Papp
2026-07-02 12:22:01 +02:00
parent 79b51a79e4
commit cf101c44b4

View File

@@ -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}
}