From bea92ba0e11dd7ffe552eed8b0fea0970f5d0393 Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Wed, 19 Apr 2017 08:33:31 -0700
Subject: [PATCH] Fix bins/opt/end2end_test
 --gtest_filter=ProxyEnd2end/ProxyEnd2endTest.RpcDeadlineExpires/1
 GRPC_POLL_STRATEGY=poll

---
 src/core/lib/surface/call.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c
index 3e96d09798..a42fe7ef3c 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.c
@@ -346,6 +346,8 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
   gpr_timespec send_deadline =
       gpr_convert_clock_type(args->send_deadline, GPR_CLOCK_MONOTONIC);
 
+  bool immediately_cancel = false;
+
   if (args->parent_call != NULL) {
     child_call *cc = call->child_call =
         gpr_arena_alloc(arena, sizeof(child_call));
@@ -386,8 +388,7 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
     if (args->propagation_mask & GRPC_PROPAGATE_CANCELLATION) {
       call->cancellation_is_inherited = 1;
       if (gpr_atm_acq_load(&args->parent_call->received_final_op_atm)) {
-        cancel_with_error(exec_ctx, call, STATUS_FROM_API_OVERRIDE,
-                          GRPC_ERROR_CANCELLED);
+        immediately_cancel = true;
       }
     }
 
@@ -422,6 +423,10 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
     cancel_with_error(exec_ctx, call, STATUS_FROM_SURFACE,
                       GRPC_ERROR_REF(error));
   }
+  if (immediately_cancel) {
+    cancel_with_error(exec_ctx, call, STATUS_FROM_API_OVERRIDE,
+                      GRPC_ERROR_CANCELLED);
+  }
   if (args->cq != NULL) {
     GPR_ASSERT(
         args->pollset_set_alternative == NULL &&
-- 
GitLab