This commit is contained in:
Arceliar 2018-07-04 21:43:42 -05:00
parent 7539c0e4fe
commit 5261bac1d8

View file

@ -589,7 +589,6 @@ func (t *switchTable) handleIn(packet []byte, idle map[switchPort]struct{}) bool
// Info about a buffered packet
type switch_packetInfo struct {
bytes []byte
//time time.Time // Timestamp of when the packet arrived
}
// Used to keep track of buffered packets
@ -600,7 +599,7 @@ type switch_buffer struct {
// Clean up old packets from buffers, to help keep latency within some reasonable bound
func (t *switchTable) cleanBuffer(b *switch_buffer) {
// TODO sane maximum buffer size, or else CoDel-like maximum time
// TODO sane maximum buffer size, or else CoDel-like maximum time
for len(b.packets) > 32 || (len(b.packets) > 0 && t.selfIsClosest(switch_getPacketCoords(b.packets[0].bytes))) {
util_putBytes(b.packets[0].bytes)
b.packets = b.packets[1:]
@ -634,12 +633,10 @@ func (t *switchTable) handleIdle(port switchPort, buffs map[string]switch_buffer
}
}
if bestSize != 0 {
t.core.log.Println("DEBUG:", []byte(best), bestSize)
buf := buffs[best]
var packet switch_packetInfo
// TODO decide if this should be LIFO or FIFO
packet, buf.packets = buf.packets[0], buf.packets[1:]
//buf.count-- // Force flooding connections to eventually yield
if len(buf.packets) == 0 {
delete(buffs, best)
} else {
@ -676,7 +673,7 @@ func (t *switchTable) doWorker() {
streamID := switch_getPacketStreamID(packet)
buf := buffs[streamID]
t.cleanBuffer(&buf)
pinfo := switch_packetInfo{packet/*, time.Now()*/}
pinfo := switch_packetInfo{packet}
buf.packets = append(buf.packets, pinfo)
buf.count++
buffs[streamID] = buf