Kepp sync.WorkerGroup.Add() outside of goroutine

The workergroup should be added before starting the worker.
The worker routine itself should not start the worker. It causes race condition.
This commit is contained in:
Hasibul Hasan Anik 2020-03-05 12:58:22 +06:00
commit 050bd28511
3 changed files with 3 additions and 4 deletions

View file

@ -227,8 +227,8 @@ func (mod *SynScanner) synScan() error {
mod.State.Store("progress", 0.0)
// start the collector
mod.waitGroup.Add(1)
go func() {
mod.waitGroup.Add(1)
defer mod.waitGroup.Done()
for packet := range mod.packets {

View file

@ -88,9 +88,8 @@ func (mod *WiFiModule) startAssoc(to net.HardwareAddr) error {
}
return fmt.Errorf("%s is an unknown BSSID or it is in the association skip list.", to.String())
}
mod.writes.Add(1)
go func() {
mod.writes.Add(1)
defer mod.writes.Done()
// since we need to change the wifi adapter channel for each

View file

@ -113,8 +113,8 @@ func (mod *WiFiModule) startDeauth(to net.HardwareAddr) error {
return fmt.Errorf("%s is an unknown BSSID, is in the deauth skip list, or doesn't have detected clients.", to.String())
}
mod.writes.Add(1)
go func() {
mod.writes.Add(1)
defer mod.writes.Done()
// since we need to change the wifi adapter channel for each