mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
optimization: optimized locking and op atomicity for the packets queue and network statistics view
This commit is contained in:
parent
3131660493
commit
305e22ee2e
3 changed files with 33 additions and 20 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue