commit 6021511ba48b10c3ef2f05c30af918a66557aa6d
parent 987b857c6dd725ea2f675dee5c42a8157ce6a06a
Author: Matthias Jaros <jaros@mailbox.org>
Date: Tue, 7 Jul 2026 23:49:43 +0200
Moved host counters into one place to have them together and actually
changed meaning of host total counter to what it actually is. a total
counter and not a done hosts counter
Diffstat:
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/it_jaros/jscanner/ProgressBar.java b/src/main/java/com/it_jaros/jscanner/ProgressBar.java
@@ -155,15 +155,15 @@ public class ProgressBar {
Counter hostCounter, Counter hostTotalCounter, Counter
socketCounter, Counter
threadCounter) {
- int doneHosts = hostTotalCounter.current();
- int runningHosts = hostCounter.current();
- int total = doneHosts + runningHosts;
- long percent = total == 0 ? 100 : doneHosts * 100L / total;
+ int total = hostTotalCounter.current();
+ int running = hostCounter.current();
+ int done = total - running;
+ long percent = total == 0 ? 100 : done * 100L / total;
String line = String.format(
"hosts: %d running, %d done | sockets: %d active, %d peak | workers: %d active, %d peak",
- runningHosts,
- doneHosts,
+ running,
+ done,
socketCounter.current(),
socketCounter.max(),
threadCounter.current(),
diff --git a/src/main/java/com/it_jaros/jscanner/Scanner.java b/src/main/java/com/it_jaros/jscanner/Scanner.java
@@ -70,6 +70,7 @@ public class Scanner implements AutoCloseable {
host -> () -> {
try {
scan.getHostCounter().inc();
+ scan.getHostTotalCounter().inc();
return scanHostPorts(host, scan);
} finally {
scan.getHostCounter().dec();
@@ -99,10 +100,9 @@ public class Scanner implements AutoCloseable {
consumer.accept(result);
}
} finally {
- scan.getHostTotalCounter().inc();
- scan.getThreadCounter().dec();
state.activeWorkers().release();
state.inPipeline().decrementAndGet();
+ scan.getThreadCounter().dec();
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();