From b17a035a05214c8066eaea613f86f176cfd7d33c Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sat, 16 May 2020 17:40:11 -0500 Subject: [PATCH] workarounds to dropping being too aggressive --- src/yggdrasil/packetqueue.go | 5 +++++ src/yggdrasil/peer.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/yggdrasil/packetqueue.go b/src/yggdrasil/packetqueue.go index 7abdaea..e37d5bb 100644 --- a/src/yggdrasil/packetqueue.go +++ b/src/yggdrasil/packetqueue.go @@ -55,6 +55,11 @@ func (q *packetQueue) drop() bool { } // Drop the oldest packet from the worst stream packet := worstStream.infos[0].packet + if q.size-uint64(len(packet)) < streamMsgSize { + // TODO something better + // We don't want to drop *all* packets, so lets save 1 batch worth... + return false + } worstStream.infos = worstStream.infos[1:] worstStream.size -= uint64(len(packet)) q.size -= uint64(len(packet)) diff --git a/src/yggdrasil/peer.go b/src/yggdrasil/peer.go index ada2921..0c195c6 100644 --- a/src/yggdrasil/peer.go +++ b/src/yggdrasil/peer.go @@ -289,7 +289,7 @@ func (p *peer) _sendPackets(packets [][]byte) { func (p *peer) _handleIdle() { var packets [][]byte var size uint64 - for size < 65535 { + for size < streamMsgSize { if packet, success := p.queue.pop(); success { packets = append(packets, packet) size += uint64(len(packet))