5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-13 00:30:28 +00:00

less aggresive queue size reduction

This commit is contained in:
Arceliar 2020-05-17 12:58:57 -05:00
parent d96ae156a1
commit ff3c8cb687

View File

@ -108,6 +108,7 @@ type peer struct {
ports map[switchPort]*peer ports map[switchPort]*peer
table *lookupTable table *lookupTable
queue packetQueue queue packetQueue
max uint64
seq uint64 // this and idle are used to detect when to drop packets from queue seq uint64 // this and idle are used to detect when to drop packets from queue
idle bool idle bool
drop bool // set to true if we're dropping packets from the queue drop bool // set to true if we're dropping packets from the queue
@ -276,14 +277,13 @@ func (p *peer) sendPacketFrom(from phony.Actor, packet []byte) {
} }
func (p *peer) _sendPacket(packet []byte) { func (p *peer) _sendPacket(packet []byte) {
size := p.queue.size
p.queue.push(packet) p.queue.push(packet)
switch { switch {
case p.idle: case p.idle:
p.idle = false p.idle = false
p._handleIdle() p._handleIdle()
case p.drop: case p.drop:
for p.queue.size > size { for p.queue.size > p.max {
p.queue.drop() p.queue.drop()
} }
default: default:
@ -306,6 +306,9 @@ func (p *peer) _handleIdle() {
p.seq++ p.seq++
p.bytesSent += uint64(size) p.bytesSent += uint64(size)
p.intf.out(packets) p.intf.out(packets)
if p.drop {
p.max = p.queue.size
}
} else { } else {
p.idle = true p.idle = true
p.drop = false p.drop = false