diff options
Diffstat (limited to 'src/cpp/server/server.cc')
-rw-r--r-- | src/cpp/server/server.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 5a4ca6915a..046133c5eb 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -107,6 +107,7 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { request_payload_(mrd->request_payload_), method_(mrd->method_) { ctx_.call_ = mrd->call_; + ctx_.cq_ = &cq_; GPR_ASSERT(mrd->in_flight_); mrd->in_flight_ = false; mrd->request_metadata_.count = 0; @@ -182,7 +183,7 @@ Server::Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned) Server::~Server() { { - std::unique_lock<std::mutex> lock(mu_); + grpc::unique_lock<grpc::mutex> lock(mu_); if (started_ && !shutdown_) { lock.unlock(); Shutdown(); @@ -247,8 +248,8 @@ bool Server::Start() { // Start processing rpcs. if (!sync_methods_.empty()) { - for (auto& m : sync_methods_) { - m.Request(server_); + for (auto m = sync_methods_.begin(); m != sync_methods_.end(); m++) { + m->Request(server_); } ScheduleCallback(); @@ -258,7 +259,7 @@ bool Server::Start() { } void Server::Shutdown() { - std::unique_lock<std::mutex> lock(mu_); + grpc::unique_lock<grpc::mutex> lock(mu_); if (started_ && !shutdown_) { shutdown_ = true; grpc_server_shutdown(server_); @@ -272,7 +273,7 @@ void Server::Shutdown() { } void Server::Wait() { - std::unique_lock<std::mutex> lock(mu_); + grpc::unique_lock<grpc::mutex> lock(mu_); while (num_running_cb_ != 0) { callback_cv_.wait(lock); } @@ -364,6 +365,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { } } ctx->call_ = call_; + ctx->cq_ = cq_; Call call(call_, server_, cq_); if (orig_status && call_) { ctx->BeginCompletionOp(&call); @@ -403,7 +405,7 @@ void Server::RequestAsyncGenericCall(GenericServerContext* context, void Server::ScheduleCallback() { { - std::unique_lock<std::mutex> lock(mu_); + grpc::unique_lock<grpc::mutex> lock(mu_); num_running_cb_++; } thread_pool_->ScheduleCallback(std::bind(&Server::RunRpc, this)); @@ -424,7 +426,7 @@ void Server::RunRpc() { } { - std::unique_lock<std::mutex> lock(mu_); + grpc::unique_lock<grpc::mutex> lock(mu_); num_running_cb_--; if (shutdown_) { callback_cv_.notify_all(); |