diff --git a/Fuzzlyn.ExecutionServer/Program.cs b/Fuzzlyn.ExecutionServer/Program.cs index 6517b78b..ae38c156 100644 --- a/Fuzzlyn.ExecutionServer/Program.cs +++ b/Fuzzlyn.ExecutionServer/Program.cs @@ -64,6 +64,9 @@ public static void Main(string[] args) return; } + // This identifier must be in sync with + // RunningExecutionServer.RequestAndReceive. + Console.Write("@!EXEC_SERVER_RESPONSE!@"); Console.WriteLine(JsonSerializer.Serialize(resp)); if (req.Kind == RequestKind.Shutdown) return; diff --git a/Fuzzlyn/RunningExecutionServer.cs b/Fuzzlyn/RunningExecutionServer.cs index 1ce7e4d9..b7dbab94 100644 --- a/Fuzzlyn/RunningExecutionServer.cs +++ b/Fuzzlyn/RunningExecutionServer.cs @@ -27,7 +27,31 @@ private ReceiveResult RequestAndReceive(Request req, TimeSpan timeout) { using var cts = new CancellationTokenSource(timeout); using var reg = cts.Token.Register(() => { killed = true; Kill(); }); - line = _process.StandardOutput.ReadLine(); + bool first = true; + while (true) + { + line = _process.StandardOutput.ReadLine(); + + if (line == null) + { + break; + } + + if (line.StartsWith("@!EXEC_SERVER_RESPONSE!@")) + { + line = line["@!EXEC_SERVER_RESPONSE!@".Length..]; + break; + } + + if (first) + { + Console.WriteLine("Received unexpected output from execution server:"); + } + + Console.WriteLine(line); + + first = false; + } } LastUseTimer.Restart(); @@ -43,20 +67,19 @@ private ReceiveResult RequestAndReceive(Request req, TimeSpan timeout) return new ReceiveResult { Ended = true, Stderr = stderr }; } - Response resp; try { - resp = JsonSerializer.Deserialize(line); + Response resp = JsonSerializer.Deserialize(line); + return new ReceiveResult { Response = resp }; } catch (JsonException ex) { - Console.WriteLine("Received malformed JSON response"); + Console.WriteLine("Could not parse JSON response"); Console.WriteLine(ex.ToString()); Console.WriteLine(line); return new ReceiveResult { Ended = true, Stderr = "Malformed result" }; } - return new ReceiveResult { Response = JsonSerializer.Deserialize(line) }; } public RunSeparatelyResults RunPair(ProgramPair pair, TimeSpan timeout)