wifi.go: dont claim read lock until it is needed

This commit is contained in:
bonedaddy 2020-12-23 13:22:48 -08:00
commit 10817d574c
No known key found for this signature in database
GPG key ID: 5386234333106B29

View file

@ -218,9 +218,6 @@ func (w *WiFi) NumHandshakes() int {
}
func (w *WiFi) SaveHandshakesTo(fileName string, linkType layers.LinkType) error {
w.RLock()
defer w.RUnlock()
// check if folder exists first
dirName := filepath.Dir(fileName)
if _, err := os.Stat(dirName); err != nil {
@ -244,6 +241,9 @@ func (w *WiFi) SaveHandshakesTo(fileName string, linkType layers.LinkType) error
}
}
w.RLock()
defer w.RUnlock()
for _, ap := range w.aps {
for _, station := range ap.Clients() {
// if half (which includes also complete) or has pmkid