From dbb79631eb7231d82114aecaa5d0c7d8be6d34a9 Mon Sep 17 00:00:00 2001
From: Vijay Pai <vpai@google.com>
Date: Tue, 3 Mar 2015 11:54:27 -0800
Subject: [PATCH] Solve the call-suppression problem earlier in the stack

---
 src/cpp/server/server.cc | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc
index 5c5b8d8286..f4410c12a5 100644
--- a/src/cpp/server/server.cc
+++ b/src/cpp/server/server.cc
@@ -287,14 +287,12 @@ void Server::Wait() {
 }
 
 void Server::PerformOpsOnCall(CallOpBuffer* buf, Call* call) {
-  if (call->call()) {
-    static const size_t MAX_OPS = 8;
-    size_t nops = MAX_OPS;
-    grpc_op ops[MAX_OPS];
-    buf->FillOps(ops, &nops);
-    GPR_ASSERT(GRPC_CALL_OK ==
-               grpc_call_start_batch(call->call(), ops, nops, buf));
-  }
+  static const size_t MAX_OPS = 8;
+  size_t nops = MAX_OPS;
+  grpc_op ops[MAX_OPS];
+  buf->FillOps(ops, &nops);
+  GPR_ASSERT(GRPC_CALL_OK ==
+             grpc_call_start_batch(call->call(), ops, nops, buf));
 }
 
 class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
@@ -326,6 +324,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
 
   bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE {
     *tag = tag_;
+    bool orig_status = *status;
     if (*status && request_) {
       if (payload_) {
         *status = DeserializeProto(payload_, request_);
@@ -345,7 +344,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
     }
     ctx_->call_ = call_;
     Call call(call_, server_, cq_);
-    if (call_) {
+    if (orig_status && call_) {
       ctx_->BeginCompletionOp(&call);
     }
     // just the pointers inside call are copied here
-- 
GitLab