Skip to content
Snippets Groups Projects
Commit 0ff932cf authored by Vijay Pai's avatar Vijay Pai
Browse files

Make sure that we hold contents of async operation until completion.

parent 739cecb0
No related branches found
No related tags found
No related merge requests found
...@@ -235,18 +235,17 @@ class AsyncQpsServerTest final : public grpc::testing::Server { ...@@ -235,18 +235,17 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
return false; return false;
} }
ResponseType response;
// Call the RPC processing function // Call the RPC processing function
grpc::Status status = invoke_method_(&req_, &response); grpc::Status status = invoke_method_(&req_, &response_);
// Have the response writer work and invoke on_finish when done // Have the response writer work and invoke on_finish when done
next_state_ = &ServerRpcContextUnaryImpl::finisher; next_state_ = &ServerRpcContextUnaryImpl::finisher;
response_writer_.Finish(response, status, AsyncQpsServerTest::tag(this)); response_writer_.Finish(response_, status, AsyncQpsServerTest::tag(this));
return true; return true;
} }
std::unique_ptr<ServerContextType> srv_ctx_; std::unique_ptr<ServerContextType> srv_ctx_;
RequestType req_; RequestType req_;
ResponseType response_;
bool (ServerRpcContextUnaryImpl::*next_state_)(bool); bool (ServerRpcContextUnaryImpl::*next_state_)(bool);
std::function<void(ServerContextType *, RequestType *, std::function<void(ServerContextType *, RequestType *,
grpc::ServerAsyncResponseWriter<ResponseType> *, void *)> grpc::ServerAsyncResponseWriter<ResponseType> *, void *)>
...@@ -298,11 +297,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server { ...@@ -298,11 +297,10 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
bool read_done(bool ok) { bool read_done(bool ok) {
if (ok) { if (ok) {
// invoke the method // invoke the method
ResponseType response;
// Call the RPC processing function // Call the RPC processing function
grpc::Status status = invoke_method_(&req_, &response); grpc::Status status = invoke_method_(&req_, &response_);
// initiate the write // initiate the write
stream_.Write(response, AsyncQpsServerTest::tag(this)); stream_.Write(response_, AsyncQpsServerTest::tag(this));
next_state_ = &ServerRpcContextStreamingImpl::write_done; next_state_ = &ServerRpcContextStreamingImpl::write_done;
} else { // client has sent writes done } else { // client has sent writes done
// finish the stream // finish the stream
...@@ -326,6 +324,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { ...@@ -326,6 +324,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
std::unique_ptr<ServerContextType> srv_ctx_; std::unique_ptr<ServerContextType> srv_ctx_;
RequestType req_; RequestType req_;
ResponseType response_;
bool (ServerRpcContextStreamingImpl::*next_state_)(bool); bool (ServerRpcContextStreamingImpl::*next_state_)(bool);
std::function<void( std::function<void(
ServerContextType *, ServerContextType *,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment