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 {