From 2c7a8d8fa737f3773d68d5b555e9d8f175b6f4fa Mon Sep 17 00:00:00 2001 From: evilsocket Date: Sun, 11 Feb 2018 05:03:06 +0100 Subject: [PATCH] misc: small fix or general refactoring i did not bother commenting --- packets/queue.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packets/queue.go b/packets/queue.go index 5611eaee..25141952 100644 --- a/packets/queue.go +++ b/packets/queue.go @@ -91,9 +91,6 @@ func (q *Queue) trackProtocols(pkt gopacket.Packet) { } func (q *Queue) trackActivity(eth *layers.Ethernet, ip4 *layers.IPv4, address net.IP, pktSize uint64) { - q.Lock() - defer q.Unlock() - // detrmine direction isSent := bytes.Compare(address, ip4.SrcIP) == 0 // push to activity channel @@ -103,6 +100,9 @@ func (q *Queue) trackActivity(eth *layers.Ethernet, ip4 *layers.IPv4, address ne Source: isSent, } + q.Lock() + defer q.Unlock() + // initialize or update stats addr := address.String() if _, found := q.Traffic[addr]; found == false {