feed: make non-blocking, engine: move around dispatch call for perf

This commit is contained in:
2026-05-12 18:06:32 +05:30
parent e3f1f5046a
commit 4d70520e43
3 changed files with 14 additions and 10 deletions
+5 -6
View File
@@ -99,14 +99,13 @@ func (e *engine) dispatch(p io.Packet) bool {
_ = e.io.SetVerdict(p, io.VerdictAcceptStream, nil)
return true
}
// Load balance by stream ID
index := p.StreamID() % uint32(len(e.workers))
packet := gopacket.NewPacket(data, layerType, gopacket.DecodeOptions{Lazy: true, NoCopy: true})
e.workers[index].Feed(&workerPacket{
StreamID: p.StreamID(),
Packet: packet,
SrcMAC: srcMAC,
DstMAC: dstMAC,
StreamID: p.StreamID(),
Data: data,
LayerType: layerType,
SrcMAC: srcMAC,
DstMAC: dstMAC,
SetVerdict: func(v io.Verdict, b []byte) error {
return e.io.SetVerdict(p, v, b)
},