mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-27 10:47:35 +00:00
wgengine/magicsock: update comment, fix earlier commit
891898525c
had a continue that meant the didCopy synchronization never ran.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
c976264bd1
commit
d74c9aa95b
@ -1134,10 +1134,13 @@ func (c *Conn) runDerpReader(ctx context.Context, derpFakeAddr netaddr.IPPort, d
|
|||||||
}
|
}
|
||||||
c.ReSTUN("derp-close")
|
c.ReSTUN("derp-close")
|
||||||
c.logf("magicsock: [%p] derp.Recv(derp-%d): %v", dc, regionID, err)
|
c.logf("magicsock: [%p] derp.Recv(derp-%d): %v", dc, regionID, err)
|
||||||
|
|
||||||
|
// Avoid excessive spinning.
|
||||||
|
// TODO: use a backoff timer, perhaps between 10ms and 500ms?
|
||||||
|
// Don't want to sleep too long. For now 250ms seems fine.
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
// Avoid excessive spinning.
|
|
||||||
case <-time.After(250 * time.Millisecond):
|
case <-time.After(250 * time.Millisecond):
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@ -1165,15 +1168,12 @@ func (c *Conn) runDerpReader(ctx context.Context, derpFakeAddr netaddr.IPPort, d
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case c.derpRecvCh <- res:
|
case c.derpRecvCh <- res:
|
||||||
continue
|
select {
|
||||||
}
|
case <-ctx.Done():
|
||||||
// The copy will not happen if connCtx is cancelled before we reach copyBuf.
|
return
|
||||||
// This has resulted in a rare inifite wait in practice.
|
case <-didCopy:
|
||||||
select {
|
continue
|
||||||
case <-ctx.Done():
|
}
|
||||||
return
|
|
||||||
case <-didCopy:
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user