Skip to content

Commit

Permalink
Logic at adding targets to the FuturesUnordered rolled back to the in…
Browse files Browse the repository at this point in the history
…itial.

In case of batchsize higher than all sockets to scan, we could end up in an infinite loop. Fixed with breaking out of the loop if that's the case.
  • Loading branch information
bergabman committed Sep 11, 2020
1 parent 6812cc3 commit b0c1ab3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/scanner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ impl Scanner {
}
}

while ftrs.len() <= self.batch_size as usize {
while ftrs.len() < self.batch_size as usize {
if !targets.is_empty() {
ftrs.push(self.scan_socket(targets.pop_front().unwrap()));
} else {
break;
}
}

loop {
match ftrs.next().await {
Some(result) => {
match result {
Ok(socket) => open_sockets.push(socket),
Err(_) => {}
if let Ok(socket) = result {
open_sockets.push(socket);
}
if !targets.is_empty() {
ftrs.push(self.scan_socket(targets.pop_front().unwrap()));
Expand Down

0 comments on commit b0c1ab3

Please sign in to comment.