optimization: optimized locking and op atomicity for the packets queue and network statistics view

This commit is contained in:
evilsocket 2018-02-05 21:04:25 +01:00
commit 305e22ee2e
3 changed files with 33 additions and 20 deletions

View file

@ -28,6 +28,9 @@ type BySentSorter []*net.Endpoint
func (a BySentSorter) Len() int { return len(a) }
func (a BySentSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a BySentSorter) Less(i, j int) bool {
session.I.Queue.Lock()
defer session.I.Queue.Unlock()
var found bool = false
var aTraffic *packets.Traffic = nil
var bTraffic *packets.Traffic = nil
@ -48,6 +51,9 @@ type ByRcvdSorter []*net.Endpoint
func (a ByRcvdSorter) Len() int { return len(a) }
func (a ByRcvdSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByRcvdSorter) Less(i, j int) bool {
session.I.Queue.Lock()
defer session.I.Queue.Unlock()
var found bool = false
var aTraffic *packets.Traffic = nil
var bTraffic *packets.Traffic = nil