Hi Roth,
Thanks for your reply, about the refer to tag, you can see greeter_async_client2.cpp, my client code is just like it, but the server code has complex work to do.
Sometimes, ok is false but call->status.ok() is true, and call->reply.message() is right. That happens very frequent in my situation, and currently, I ignore it, do not check ok, and the program working properly, but I worried if there will some undefined things happen.
So that confused me, if the response of the grpc server is correct, why the ok equals false?
void AsyncCompleteRpc() {
void* got_tag;
bool ok = false;
// Block until the next result is available in the completion queue "cq".
while (cq_.Next(&got_tag, &ok)) {
// The tag in this example is the memory location of the call object
AsyncClientCall* call = static_cast<AsyncClientCall*>(got_tag);
// Verify that the request was completed successfully. Note that "ok"
// corresponds solely to the request for updates introduced by Finish().
GPR_ASSERT(ok);
if (call->status.ok())
std::cout << "Greeter received: " << call->reply.message() << std::endl;
else
std::cout << "RPC failed" << std::endl;
// Once we're complete, deallocate the call object.
delete call;
}
}
在 2017年9月1日星期五 UTC+8下午10:10:25,Mark D. Roth写道: