From 9618fbf0448be2505e9d19d83a4c913e0e9d71c8 Mon Sep 17 00:00:00 2001 From: PJ Date: Thu, 14 Mar 2024 20:18:25 +0100 Subject: [PATCH] autopilog: fix race --- autopilot/scanner.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/autopilot/scanner.go b/autopilot/scanner.go index b71e2edbc..4c15f0bbe 100644 --- a/autopilot/scanner.go +++ b/autopilot/scanner.go @@ -193,8 +193,10 @@ func (s *scanner) tryPerformHostScan(ctx context.Context, w scanWorker, force bo s.logger.Infof("%s started", scanType) s.wg.Add(1) + s.ap.wg.Add(1) go func(st string) { defer s.wg.Done() + defer s.ap.wg.Done() for resp := range s.launchScanWorkers(ctx, w, s.launchHostScans()) { if s.isInterrupted() || s.ap.isStopped() { @@ -250,10 +252,7 @@ func (s *scanner) tryUpdateTimeout() { func (s *scanner) launchHostScans() chan scanReq { reqChan := make(chan scanReq, s.scanBatchSize) - - s.ap.wg.Add(1) go func() { - defer s.ap.wg.Done() defer close(reqChan) var offset int