tsnet: fix slow test shutdown leading to flakes
TestDial in particular sometimes gets stuck in CI for minutes, letting chantun drop packets during shutdown avoids blocking shutdown. Updates #18423 Signed-off-by: James Tucker <jftucker@gmail.com>
This commit is contained in:
+6
-2
@@ -1881,8 +1881,8 @@ type chanTUN struct {
|
|||||||
|
|
||||||
func newChanTUN() *chanTUN {
|
func newChanTUN() *chanTUN {
|
||||||
t := &chanTUN{
|
t := &chanTUN{
|
||||||
Inbound: make(chan []byte, 10),
|
Inbound: make(chan []byte, 1024),
|
||||||
Outbound: make(chan []byte, 10),
|
Outbound: make(chan []byte, 1024),
|
||||||
closed: make(chan struct{}),
|
closed: make(chan struct{}),
|
||||||
events: make(chan tun.Event, 1),
|
events: make(chan tun.Event, 1),
|
||||||
}
|
}
|
||||||
@@ -1922,6 +1922,10 @@ func (t *chanTUN) Write(bufs [][]byte, offset int) (int, error) {
|
|||||||
case <-t.closed:
|
case <-t.closed:
|
||||||
return 0, errors.New("closed")
|
return 0, errors.New("closed")
|
||||||
case t.Inbound <- slices.Clone(pkt):
|
case t.Inbound <- slices.Clone(pkt):
|
||||||
|
default:
|
||||||
|
// Drop the packet if the channel is full, like a real
|
||||||
|
// TUN under congestion. This avoids blocking the
|
||||||
|
// WireGuard send path when no goroutine is draining.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len(bufs), nil
|
return len(bufs), nil
|
||||||
|
|||||||
Reference in New Issue
Block a user