Skip to content

Commit 099f633

Browse files
josharianzx2c4
authored andcommitted
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 <[email protected]>
1 parent f8243bc commit 099f633

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

device/receive.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind conn.Bind) {
199199
if device.addToInboundAndDecryptionQueues(peer.queue.inbound, device.queue.decryption, elem) {
200200
buffer = device.GetMessageBuffer()
201201
}
202+
} else {
203+
device.PutInboundElement(elem)
202204
}
203205
peer.queue.RUnlock()
204206

0 commit comments

Comments
 (0)