mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-14 16:10:29 +00:00
prioritize sending from small queues that have been blocked for a long time
This commit is contained in:
parent
7da4967f5e
commit
1a65c065d0
@ -640,19 +640,21 @@ func (t *switchTable) handleIdle(port switchPort, bufs *switch_buffers) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
var best string
|
var best string
|
||||||
var bestSize uint64
|
var bestPriority float64
|
||||||
bufs.cleanup(t)
|
bufs.cleanup(t)
|
||||||
|
now := time.Now()
|
||||||
for streamID, buf := range bufs.bufs {
|
for streamID, buf := range bufs.bufs {
|
||||||
// Filter over the streams that this node is closer to
|
// Filter over the streams that this node is closer to
|
||||||
// Keep the one with the smallest queue
|
// Keep the one with the smallest queue
|
||||||
packet := buf.packets[0]
|
packet := buf.packets[0]
|
||||||
coords := switch_getPacketCoords(packet.bytes)
|
coords := switch_getPacketCoords(packet.bytes)
|
||||||
if (bestSize == 0 || buf.size < bestSize) && t.portIsCloser(coords, port) {
|
priority := float64(now.Sub(packet.time)) / float64(buf.size)
|
||||||
|
if priority > bestPriority && t.portIsCloser(coords, port) {
|
||||||
best = streamID
|
best = streamID
|
||||||
bestSize = buf.size
|
bestPriority = priority
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if bestSize != 0 {
|
if bestPriority != 0 {
|
||||||
buf := bufs.bufs[best]
|
buf := bufs.bufs[best]
|
||||||
var packet switch_packetInfo
|
var packet switch_packetInfo
|
||||||
// TODO decide if this should be LIFO or FIFO
|
// TODO decide if this should be LIFO or FIFO
|
||||||
|
Loading…
Reference in New Issue
Block a user