1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 01:05:15 +01:00

device: remove QueueInboundElement leak with stopped peers

This is particularly problematic on mobile,
where there is a fixed number of elements.
If most of them leak, it'll impact performance;
if all of them leak, the device will permanently deadlock.

I have a test that detects element leaks, which is how I found this one.
There are some remaining leaks that I have not yet tracked down,
but this is the most prominent by far.

I will commit the test when it passes reliably.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder 2020-12-22 09:52:53 -08:00 committed by Jason A. Donenfeld
parent a1c265b0c5
commit b5f966ac24

View File

@ -199,6 +199,8 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind conn.Bind) {
if device.addToInboundAndDecryptionQueues(peer.queue.inbound, device.queue.decryption, elem) { if device.addToInboundAndDecryptionQueues(peer.queue.inbound, device.queue.decryption, elem) {
buffer = device.GetMessageBuffer() buffer = device.GetMessageBuffer()
} }
} else {
device.PutInboundElement(elem)
} }
peer.queue.RUnlock() peer.queue.RUnlock()