Skip to content

Commit 0fce8c4

Browse files
committed
Prevents blocking when waiting for idle timeout
1 parent 6a50156 commit 0fce8c4

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

pkg/scanner/arpscan.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ func (s *ArpScanner) Scan() error {
127127
})
128128
}
129129

130-
time.Sleep(s.idleTimeout)
130+
time.AfterFunc(s.idleTimeout, func() {
131+
go s.Stop()
131132

132-
go s.Stop()
133-
134-
go func() {
135-
s.resultChan <- &ScanResult{
136-
Type: ARPDone,
137-
}
138-
}()
133+
go func() {
134+
s.resultChan <- &ScanResult{
135+
Type: ARPDone,
136+
}
137+
}()
138+
})
139139

140140
return err
141141
}

pkg/scanner/synscan.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ func (s *SynScanner) Scan() error {
156156
}
157157
}
158158

159-
time.Sleep(s.idleTimeout)
159+
time.AfterFunc(s.idleTimeout, func() {
160+
go s.Stop()
160161

161-
go s.Stop()
162-
163-
go func() {
164-
s.resultChan <- &ScanResult{
165-
Type: SYNDone,
166-
}
167-
}()
162+
go func() {
163+
s.resultChan <- &ScanResult{
164+
Type: SYNDone,
165+
}
166+
}()
167+
})
168168

169169
return nil
170170
}

0 commit comments

Comments
 (0)