mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 14:10:28 +00:00
workarounds to dropping being too aggressive
This commit is contained in:
parent
b132560f65
commit
b17a035a05
@ -55,6 +55,11 @@ func (q *packetQueue) drop() bool {
|
|||||||
}
|
}
|
||||||
// Drop the oldest packet from the worst stream
|
// Drop the oldest packet from the worst stream
|
||||||
packet := worstStream.infos[0].packet
|
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.infos = worstStream.infos[1:]
|
||||||
worstStream.size -= uint64(len(packet))
|
worstStream.size -= uint64(len(packet))
|
||||||
q.size -= uint64(len(packet))
|
q.size -= uint64(len(packet))
|
||||||
|
@ -289,7 +289,7 @@ func (p *peer) _sendPackets(packets [][]byte) {
|
|||||||
func (p *peer) _handleIdle() {
|
func (p *peer) _handleIdle() {
|
||||||
var packets [][]byte
|
var packets [][]byte
|
||||||
var size uint64
|
var size uint64
|
||||||
for size < 65535 {
|
for size < streamMsgSize {
|
||||||
if packet, success := p.queue.pop(); success {
|
if packet, success := p.queue.pop(); success {
|
||||||
packets = append(packets, packet)
|
packets = append(packets, packet)
|
||||||
size += uint64(len(packet))
|
size += uint64(len(packet))
|
||||||
|
Loading…
Reference in New Issue
Block a user