make the reconnect delay interruptible by the session context

This commit is contained in:
Jay
2026-08-11 14:40:12 -04:00
parent 53cb949d2b
commit 6586671c68
2 changed files with 33 additions and 2 deletions
+8 -2
View File
@@ -316,8 +316,14 @@ func (w *session) reset(ctx context.Context) bool {
default:
}
// refresh session
time.Sleep(w.config.ReconnectDelay)
// refresh session timeout
timer := time.NewTimer(w.config.ReconnectDelay)
select {
case <-ctx.Done():
timer.Stop()
return false
case <-timer.C:
}
w.restartCount.Add(1)
return true
}