Skip to content

Commit 23918ae

Browse files
committed
fix(backend, transport): enable packet pool
1 parent b2d6a88 commit 23918ae

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

backend/pkg/transport/packet/data/decoder.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ func (decoder *Decoder) Decode(id abstraction.PacketId, reader io.Reader) (abstr
3535
return nil, ErrUnexpectedId{Id: id}
3636
}
3737

38-
//packet := GetPacket(id)
39-
packet := NewPacket(id)
38+
packet := GetPacket(id)
4039
for _, value := range descriptor {
4140
val, err := value.Decode(decoder.endianness, reader)
4241
if err != nil {

backend/pkg/transport/transport.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ func (transport *Transport) readLoopTCPConn(conn net.Conn, logger zerolog.Logger
260260
logger.Trace().Type("type", packet).Msg("packet")
261261
transport.api.Notification(NewPacketNotification(packet, from, to, time.Now()))
262262

263-
//if dataPacket, ok := packet.(*data.Packet); ok {
264-
// data.ReleasePacket(dataPacket)
265-
//}
263+
if dataPacket, ok := packet.(*data.Packet); ok {
264+
data.ReleasePacket(dataPacket)
265+
}
266266
}
267267
}()
268268
}
@@ -469,9 +469,9 @@ func (transport *Transport) handleUDPPacket(udpPacket udp.Packet) {
469469
// Send notification
470470
transport.api.Notification(NewPacketNotification(packet, srcAddr, dstAddr, udpPacket.Timestamp))
471471

472-
//if dataPacket, ok := packet.(*data.Packet); ok {
473-
// data.ReleasePacket(dataPacket)
474-
//s}
472+
if dataPacket, ok := packet.(*data.Packet); ok {
473+
data.ReleasePacket(dataPacket)
474+
}
475475
}
476476

477477
// handleConversation is called when the sniffer detects a new conversation and handles its specific packets
@@ -497,9 +497,9 @@ func (transport *Transport) handleConversation(socket network.Socket, reader io.
497497
// Send notification
498498
transport.api.Notification(NewPacketNotification(packet, srcAddr, dstAddr, time.Now()))
499499

500-
//if dataPacket, ok := packet.(*data.Packet); ok {
501-
// data.ReleasePacket(dataPacket)
502-
//}
500+
if dataPacket, ok := packet.(*data.Packet); ok {
501+
data.ReleasePacket(dataPacket)
502+
}
503503
}
504504
}()
505505
}

0 commit comments

Comments
 (0)