From 90391dbbcf72370ab8ed92e2ae0faead77104a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Sobala?= Date: Wed, 30 Dec 2015 09:30:41 +0100 Subject: [PATCH] Change CallData status before notifying CompletionQueue --- examples/cpp/helloworld/greeter_async_server.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/cpp/helloworld/greeter_async_server.cc b/examples/cpp/helloworld/greeter_async_server.cc index b2047a8ce5c..d06e7c71489 100644 --- a/examples/cpp/helloworld/greeter_async_server.cc +++ b/examples/cpp/helloworld/greeter_async_server.cc @@ -94,6 +94,9 @@ class ServerImpl final { void Proceed() { if (status_ == CREATE) { + // Make this instance progress to the PROCESS state. + status_ = PROCESS; + // As part of the initial CREATE state, we *request* that the system // start processing SayHello requests. In this request, "this" acts are // the tag uniquely identifying the request (so that different CallData @@ -101,8 +104,6 @@ class ServerImpl final { // the memory address of this CallData instance. service_->RequestSayHello(&ctx_, &request_, &responder_, cq_, cq_, this); - // Make this instance progress to the PROCESS state. - status_ = PROCESS; } else if (status_ == PROCESS) { // Spawn a new CallData instance to serve new clients while we process // the one for this CallData. The instance will deallocate itself as @@ -116,8 +117,8 @@ class ServerImpl final { // And we are done! Let the gRPC runtime know we've finished, using the // memory address of this instance as the uniquely identifying tag for // the event. - responder_.Finish(reply_, Status::OK, this); status_ = FINISH; + responder_.Finish(reply_, Status::OK, this); } else { GPR_ASSERT(status_ == FINISH); // Once in the FINISH state, deallocate ourselves (CallData).