Fix potential goroutine leak in syncs/watchdog.go

Depending on how the preemption will occur, in some scenarios sendc
would have blocked indefinitely even after cancelling the context.

Fixes #10315

Signed-off-by: Uri Gorelik <uri.gore@gmail.com>
This commit is contained in:
Uri Gorelik 2023-11-18 08:33:47 -05:00 committed by Denton Gentry
parent e7cad78b00
commit b88929edf8

View File

@ -29,7 +29,10 @@ func Watch(ctx context.Context, mu sync.Locker, tick, max time.Duration) chan ti
// Drop values written after c is closed. // Drop values written after c is closed.
return return
} }
c <- d select {
case c <- d:
case <-ctx.Done():
}
} }
closec := func() { closec := func() {
closemu.Lock() closemu.Lock()