Skip to content

Commit

Permalink
Fix CPU loop in sync server
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Sep 3, 2021
1 parent bdab457 commit 15ac33d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sync/src/main/java/org/mvndaemon/mvnd/sync/IpcServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,19 @@ private void use() {
private void expirationCheck() {
while (true) {
long current = System.nanoTime();
if (current - lastUsed > idleTimeout) {
long left = (lastUsed + idleTimeout) - current;
if (left < 0) {
info("IpcServer expired, closing");
close();
break;
} else {
try {
Thread.sleep(TimeUnit.NANOSECONDS.toMillis(left));
} catch (InterruptedException e) {
info("IpcServer expiration check interrupted, closing");
close();
break;
}
}
}
}
Expand Down

0 comments on commit 15ac33d

Please sign in to comment.