mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 06:20:26 +00:00
have the switch queue drop packts to ourself when the total size of all packets is at least queueTotalMaxSize, instead of an arbitrary unconfigurable packet count
This commit is contained in:
parent
6803f209b0
commit
c55d7b4705
@ -814,17 +814,23 @@ func (t *switchTable) doWorker() {
|
||||
go func() {
|
||||
// Keep taking packets from the idle worker and sending them to the above whenever it's idle, keeping anything extra in a (fifo, head-drop) buffer
|
||||
var buf [][]byte
|
||||
var size int
|
||||
for {
|
||||
buf = append(buf, <-t.toRouter)
|
||||
bs := <-t.toRouter
|
||||
size += len(bs)
|
||||
buf = append(buf, bs)
|
||||
for len(buf) > 0 {
|
||||
select {
|
||||
case bs := <-t.toRouter:
|
||||
size += len(bs)
|
||||
buf = append(buf, bs)
|
||||
for len(buf) > 32 {
|
||||
for size > int(t.queueTotalMaxSize) {
|
||||
size -= len(buf[0])
|
||||
util.PutBytes(buf[0])
|
||||
buf = buf[1:]
|
||||
}
|
||||
case sendingToRouter <- buf[0]:
|
||||
size -= len(buf[0])
|
||||
buf = buf[1:]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user