Fix InputPackets exceeding device batch size
This commit is contained in:
parent
7a66fbee4a
commit
da8671622b
1 changed files with 2 additions and 1 deletions
|
|
@ -447,6 +447,7 @@ type InputPacketRef struct {
|
|||
|
||||
func (device *Device) InputPackets(packets []*InputPacketRef) []*InputPacketRef {
|
||||
var unmatched []*InputPacketRef
|
||||
batchSize := device.BatchSize()
|
||||
elemsByPeer := make(map[*Peer][]*QueueOutboundElementsContainer, len(packets))
|
||||
for _, packetRef := range packets {
|
||||
peer := device.allowedips.Lookup(packetRef.Destination)
|
||||
|
|
@ -475,7 +476,7 @@ func (device *Device) InputPackets(packets []*InputPacketRef) []*InputPacketRef
|
|||
}
|
||||
elem.packet = packet[:n]
|
||||
containers := elemsByPeer[peer]
|
||||
if len(containers) == 0 || len(containers[len(containers)-1].elems) >= conn.IdealBatchSize {
|
||||
if len(containers) == 0 || len(containers[len(containers)-1].elems) >= batchSize {
|
||||
containers = append(containers, device.GetOutboundElementsContainer())
|
||||
elemsByPeer[peer] = containers
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue