From 0823cb786b873ce5e6d180dd279865742580e3a3 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 2 Mar 2015 15:48:51 -0800 Subject: [PATCH] Sanity checks for calls that were causing crashes --- src/cpp/server/server.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 97bf0f1a6ea..5c5b8d8286e 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -287,12 +287,14 @@ void Server::Wait() { } void Server::PerformOpsOnCall(CallOpBuffer* buf, 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)); + 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)); + } } class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { @@ -343,7 +345,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { } ctx_->call_ = call_; Call call(call_, server_, cq_); - ctx_->BeginCompletionOp(&call); + if (call_) { + ctx_->BeginCompletionOp(&call); + } // just the pointers inside call are copied here stream_->BindCall(&call); delete this;