aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar Przemysław Sobala <przemyslaw.sobala@grupawp.pl>2015-12-30 09:30:41 +0100
committerGravatar Przemysław Sobala <przemyslaw.sobala@grupawp.pl>2015-12-30 09:32:02 +0100
commit90391dbbcf72370ab8ed92e2ae0faead77104a94 (patch)
treedcd5e150e22e662c8e7c22878840b99f55616a22 /examples
parent7593cff337629ca179302ddf6ce2cbedbbbcab73 (diff)
Change CallData status before notifying CompletionQueue
Diffstat (limited to 'examples')
-rw-r--r--examples/cpp/helloworld/greeter_async_server.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/cpp/helloworld/greeter_async_server.cc b/examples/cpp/helloworld/greeter_async_server.cc
index b2047a8ce5..d06e7c7148 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).