From 827bac6ac97c25e20fcf1f97031e1969b7bcede7 Mon Sep 17 00:00:00 2001 From: Michajlo Matijkiw Date: Thu, 15 Sep 2016 18:05:40 +0000 Subject: Send the client the command id as soon as possible Previously the client was dependent on stdout/stderr or other interactions to receive the command id, which is necessary to cancel the command. Send the command id right away so we can cancel sooner. -- MOS_MIGRATED_REVID=133282720 --- .../google/devtools/build/lib/server/GrpcServerImpl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/main/java/com') diff --git a/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java b/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java index 1daa6e9d9c..13837415f0 100644 --- a/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java +++ b/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java @@ -625,6 +625,19 @@ public class GrpcServerImpl extends RPCServer { try (RunningCommand command = new RunningCommand()) { commandId = command.id; + + try { + // Send the client the command id as soon as we know it. + observer.onNext( + RunResponse.newBuilder() + .setCookie(responseCookie) + .setCommandId(commandId) + .build()); + } catch (StatusRuntimeException e) { + log.info( + "The client cancelled the command before receiving the command id: " + e.getMessage()); + } + OutErr rpcOutErr = OutErr.create( new RpcOutputStream(command.id, StreamType.STDOUT, sink), -- cgit v1.2.3