]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: remove QueueInboundElement leak with stopped peers
authorJosh Bleecher Snyder <josh@tailscale.com>
Tue, 22 Dec 2020 17:52:53 +0000 (09:52 -0800)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 7 Jan 2021 13:49:44 +0000 (14:49 +0100)
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>
device/receive.go

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