aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/server
diff options
context:
space:
mode:
authorGravatar Michajlo Matijkiw <michajlo@google.com>2016-09-15 18:05:40 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-09-16 07:59:03 +0000
commit827bac6ac97c25e20fcf1f97031e1969b7bcede7 (patch)
tree12ebc0c9ecd743c76a858a1a4ba839ebcff7f8f4 /src/main/java/com/google/devtools/build/lib/server
parentd93706d6ab930b09c1df2ca728e8b6824b90e9e2 (diff)
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
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/server')
-rw-r--r--src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java13
1 files changed, 13 insertions, 0 deletions
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),