From ba4047b51a7db87a0e13df7221f39a6fc66e048b Mon Sep 17 00:00:00 2001 From: Arceliar Date: Fri, 6 Jul 2018 17:27:04 -0500 Subject: [PATCH] correctly update buffer sizs when buffers overflow, and returned freed packets to the byte store --- src/yggdrasil/switch.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/yggdrasil/switch.go b/src/yggdrasil/switch.go index ea52fdc9..6fe50bf3 100644 --- a/src/yggdrasil/switch.go +++ b/src/yggdrasil/switch.go @@ -631,8 +631,12 @@ func (b *switch_buffers) cleanup(t *switchTable) { packet, buf.packets = buf.packets[0], buf.packets[1:] buf.size -= uint64(len(packet.bytes)) b.size -= uint64(len(packet.bytes)) + util_putBytes(packet.bytes) if len(buf.packets) == 0 { delete(b.bufs, streamID) + } else { + // Need to update the map, since buf was retrieved by value + b.bufs[streamID] = buf } break } @@ -672,6 +676,7 @@ func (t *switchTable) handleIdle(port switchPort, bufs *switch_buffers) bool { if len(buf.packets) == 0 { delete(bufs.bufs, best) } else { + // Need to update the map, since buf was retrieved by value bufs.bufs[best] = buf } to.sendPacket(packet.bytes)