From 0fce8c400722537e356c24d48e55268f5d04e73c Mon Sep 17 00:00:00 2001 From: Rob Gonnella Date: Mon, 15 Jul 2024 09:30:57 -0400 Subject: [PATCH] Prevents blocking when waiting for idle timeout --- pkg/scanner/arpscan.go | 16 ++++++++-------- pkg/scanner/synscan.go | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/scanner/arpscan.go b/pkg/scanner/arpscan.go index a2cdba3..5980a27 100644 --- a/pkg/scanner/arpscan.go +++ b/pkg/scanner/arpscan.go @@ -127,15 +127,15 @@ func (s *ArpScanner) Scan() error { }) } - time.Sleep(s.idleTimeout) + time.AfterFunc(s.idleTimeout, func() { + go s.Stop() - go s.Stop() - - go func() { - s.resultChan <- &ScanResult{ - Type: ARPDone, - } - }() + go func() { + s.resultChan <- &ScanResult{ + Type: ARPDone, + } + }() + }) return err } diff --git a/pkg/scanner/synscan.go b/pkg/scanner/synscan.go index 4f169ed..e18b3bc 100644 --- a/pkg/scanner/synscan.go +++ b/pkg/scanner/synscan.go @@ -156,15 +156,15 @@ func (s *SynScanner) Scan() error { } } - time.Sleep(s.idleTimeout) + time.AfterFunc(s.idleTimeout, func() { + go s.Stop() - go s.Stop() - - go func() { - s.resultChan <- &ScanResult{ - Type: SYNDone, - } - }() + go func() { + s.resultChan <- &ScanResult{ + Type: SYNDone, + } + }() + }) return nil }