mirror of
https://git.zx2c4.com/wireguard-go
synced 2024-11-15 01:05:15 +01:00
device: prevent spurious errors while closing a device
When closing a device, packets that are in flight can make it to SendBuffer, which then returns an error. Those errors add noise but no light; they do not reflect an actual problem. Adding the synchronization required to prevent this from occurring is currently expensive and error-prone. Instead, quietly drop such packets instead of returning an error. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
c9e4a859ae
commit
fc0aabbae9
@ -140,6 +140,11 @@ func (peer *Peer) SendBuffer(buffer []byte) error {
|
|||||||
defer peer.device.net.RUnlock()
|
defer peer.device.net.RUnlock()
|
||||||
|
|
||||||
if peer.device.net.bind == nil {
|
if peer.device.net.bind == nil {
|
||||||
|
// Packets can leak through to SendBuffer while the device is closing.
|
||||||
|
// When that happens, drop them silently to avoid spurious errors.
|
||||||
|
if peer.device.isClosed.Get() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return errors.New("no bind")
|
return errors.New("no bind")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user