From 9713f9469a5b1ba11b717a1158e96f8c639c2918 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Wed, 22 May 2024 10:51:30 +0200 Subject: [PATCH] improve diagnostics for unknown CompilerDaemon requests and be more lenient before shutting down --- .../mxtool/compilerserver/CompilerDaemon.java | 17 +++++++++++++++-- src/mx/_impl/mx.py | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/java/com.oracle.mxtool.compilerserver/src/com/oracle/mxtool/compilerserver/CompilerDaemon.java b/java/com.oracle.mxtool.compilerserver/src/com/oracle/mxtool/compilerserver/CompilerDaemon.java index 722fc913..2eb364f5 100644 --- a/java/com.oracle.mxtool.compilerserver/src/com/oracle/mxtool/compilerserver/CompilerDaemon.java +++ b/java/com.oracle.mxtool.compilerserver/src/com/oracle/mxtool/compilerserver/CompilerDaemon.java @@ -31,6 +31,7 @@ import java.net.Socket; import java.net.SocketException; import java.time.Instant; +import java.util.Formatter; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; @@ -46,7 +47,7 @@ public abstract class CompilerDaemon { /** * The deamon will shut down after receiving this many requests with an unrecognized header. */ - static final int MAX_UNRECOGNIZED_REQUESTS = 1000; + static final int MAX_UNRECOGNIZED_REQUESTS = 10_000; protected void logf(String format, Object... args) { if (verbose) { @@ -128,6 +129,18 @@ public Connection(Socket connectionSocket, Compiler compiler) { this.compiler = compiler; } + private String printable(String s) { + Formatter buf = new Formatter(); + s.chars().forEach(c -> { + if (c < 0x20 || c >= 0x7F) { + buf.format("\\u%04x", c); + } else { + buf.format("%c", c); + } + }); + return buf.toString(); + } + @Override public void run() { try { @@ -161,8 +174,8 @@ public void run() { output.write(result + "\n"); } else { - System.err.printf("%sUnrecognized request (len=%d): \"%s\"%n", prefix, request.length(), request); int unrecognizedRequestCount = unrecognizedRequests.incrementAndGet(); + System.err.printf("%sUnrecognized request %d (len=%d): \"%s\"%n", prefix, unrecognizedRequestCount, request.length(), printable(request)); if (unrecognizedRequestCount > MAX_UNRECOGNIZED_REQUESTS) { System.err.printf("%sShutting down after receiving %d unrecognized requests%n", prefix, unrecognizedRequestCount); System.exit(0); diff --git a/src/mx/_impl/mx.py b/src/mx/_impl/mx.py index 10f4c4ba..5fc8d19f 100755 --- a/src/mx/_impl/mx.py +++ b/src/mx/_impl/mx.py @@ -18173,7 +18173,7 @@ def alarm_handler(signum, frame): _CACHE_DIR = get_env('MX_CACHE_DIR', join(dot_mx_dir(), 'cache')) # The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue -version = VersionSpec("7.25.6") # GR-54131 Fix codeowners incorrectly computing absolute file names for files from 'git diff' +version = VersionSpec("7.25.7") # GR-54207 - improve diagnostics for unknown CompilerDaemon requests _mx_start_datetime = datetime.utcnow()