wgengine/magicsock: make time.Sleep in runDerpReader respect cancellation.
Before this patch, the 250ms sleep would not be interrupted by context cancellation, which would result in the goroutine sometimes lingering in tests (100ms grace period). Signed-off-by: Dmytro Shynkevych <dmytro@tailscale.com>
This commit is contained in:
parent
891898525c
commit
380ee76d00
|
@ -1134,7 +1134,12 @@ func (c *Conn) runDerpReader(ctx context.Context, derpFakeAddr netaddr.IPPort, d
|
|||
}
|
||||
c.ReSTUN("derp-close")
|
||||
c.logf("magicsock: [%p] derp.Recv(derp-%d): %v", dc, regionID, err)
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
// Avoid excessive spinning.
|
||||
case <-time.Sleep(250 * time.Millisecond):
|
||||
}
|
||||
continue
|
||||
}
|
||||
switch m := msg.(type) {
|
||||
|
|
Loading…
Reference in New Issue