aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-05-20 11:17:20 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-05-20 11:17:20 -0700
commit8a7fe1a0eff0981a470596845ec23bf05825c3b4 (patch)
tree2ec92fc0b8dd8c672bc103f5f607de847508e9f0 /src
parent139040b8be764a0eaa5c142b06d97c2476fd4d19 (diff)
Fix crash
Diffstat (limited to 'src')
-rw-r--r--src/cpp/server/server_builder.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc
index daa79e5ae9..5966e548b0 100644
--- a/src/cpp/server/server_builder.cc
+++ b/src/cpp/server/server_builder.cc
@@ -100,10 +100,12 @@ void ServerBuilder::AddListeningPort(const grpc::string& addr,
std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
std::unique_ptr<ThreadPoolInterface> thread_pool;
+ bool has_sync_methods = false;
for (auto it = services_.begin(); it != services_.end(); ++it) {
if ((*it)->service->has_synchronous_methods()) {
if (thread_pool == nullptr) {
thread_pool.reset(CreateDefaultThreadPool());
+ has_sync_methods = true;
break;
}
}
@@ -133,7 +135,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
// If the server has atleast one sync methods, we know that this is a Sync
// server or a Hybrid server and the completion queue (server->cq_) would be
// frequently polled.
- int num_frequently_polled_cqs = (thread_pool != nullptr) ? 1 : 0;
+ int num_frequently_polled_cqs = has_sync_methods ? 1 : 0;
for (auto cq = cqs_.begin(); cq != cqs_.end(); ++cq) {
// A completion queue that is not polled frequently (by calling Next() or