mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-12-24 01:05:41 +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() {
|
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
|
// 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 buf [][]byte
|
||||||
|
var size int
|
||||||
for {
|
for {
|
||||||
buf = append(buf, <-t.toRouter)
|
bs := <-t.toRouter
|
||||||
|
size += len(bs)
|
||||||
|
buf = append(buf, bs)
|
||||||
for len(buf) > 0 {
|
for len(buf) > 0 {
|
||||||
select {
|
select {
|
||||||
case bs := <-t.toRouter:
|
case bs := <-t.toRouter:
|
||||||
|
size += len(bs)
|
||||||
buf = append(buf, bs)
|
buf = append(buf, bs)
|
||||||
for len(buf) > 32 {
|
for size > int(t.queueTotalMaxSize) {
|
||||||
|
size -= len(buf[0])
|
||||||
util.PutBytes(buf[0])
|
util.PutBytes(buf[0])
|
||||||
buf = buf[1:]
|
buf = buf[1:]
|
||||||
}
|
}
|
||||||
case sendingToRouter <- buf[0]:
|
case sendingToRouter <- buf[0]:
|
||||||
|
size -= len(buf[0])
|
||||||
buf = buf[1:]
|
buf = buf[1:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user