aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpp')
-rw-r--r--src/cpp/common/core_codegen.cc9
-rw-r--r--src/cpp/common/version_cc.cc2
-rw-r--r--src/cpp/server/server_builder.cc5
-rw-r--r--src/cpp/server/server_cc.cc25
-rw-r--r--src/cpp/server/server_context.cc4
5 files changed, 31 insertions, 14 deletions
diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc
index 43dffe7a2a..0dd758ec4e 100644
--- a/src/cpp/common/core_codegen.cc
+++ b/src/cpp/common/core_codegen.cc
@@ -54,9 +54,14 @@ struct grpc_byte_buffer;
namespace grpc {
-grpc_completion_queue* CoreCodegen::grpc_completion_queue_create(
+grpc_completion_queue* CoreCodegen::grpc_completion_queue_create_for_next(
void* reserved) {
- return ::grpc_completion_queue_create(reserved);
+ return ::grpc_completion_queue_create_for_next(reserved);
+}
+
+grpc_completion_queue* CoreCodegen::grpc_completion_queue_create_for_pluck(
+ void* reserved) {
+ return ::grpc_completion_queue_create_for_pluck(reserved);
}
void CoreCodegen::grpc_completion_queue_destroy(grpc_completion_queue* cq) {
diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc
index f5a0e4131d..72a4c4cf94 100644
--- a/src/cpp/common/version_cc.cc
+++ b/src/cpp/common/version_cc.cc
@@ -37,5 +37,5 @@
#include <grpc++/grpc++.h>
namespace grpc {
-grpc::string Version() { return "1.3.0-dev"; }
+grpc::string Version() { return "1.4.0-dev"; }
}
diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc
index 4eb4b5a1b2..3a15afc49e 100644
--- a/src/cpp/server/server_builder.cc
+++ b/src/cpp/server/server_builder.cc
@@ -337,10 +337,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
}
auto cqs_data = cqs_.empty() ? nullptr : &cqs_[0];
- if (!server->Start(cqs_data, cqs_.size())) {
- if (added_port) server->Shutdown();
- return nullptr;
- }
+ server->Start(cqs_data, cqs_.size());
for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) {
(*plugin)->Finish(initializer);
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index ce173a1ee2..75610d69cd 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -124,6 +124,14 @@ class ShutdownTag : public CompletionQueueTag {
bool FinalizeResult(void** tag, bool* status) { return false; }
};
+class DummyTag : public CompletionQueueTag {
+ public:
+ bool FinalizeResult(void** tag, bool* status) {
+ *status = true;
+ return true;
+ }
+};
+
class Server::SyncRequest final : public CompletionQueueTag {
public:
SyncRequest(RpcServiceMethod* method, void* tag)
@@ -145,7 +153,7 @@ class Server::SyncRequest final : public CompletionQueueTag {
grpc_metadata_array_destroy(&request_metadata_);
}
- void SetupRequest() { cq_ = grpc_completion_queue_create(nullptr); }
+ void SetupRequest() { cq_ = grpc_completion_queue_create_for_pluck(nullptr); }
void TeardownRequest() {
grpc_completion_queue_destroy(cq_);
@@ -213,10 +221,15 @@ class Server::SyncRequest final : public CompletionQueueTag {
MethodHandler::HandlerParameter(&call_, &ctx_, request_payload_));
global_callbacks->PostSynchronousRequest(&ctx_);
request_payload_ = nullptr;
- void* ignored_tag;
- bool ignored_ok;
+
cq_.Shutdown();
- GPR_ASSERT(cq_.Next(&ignored_tag, &ignored_ok) == false);
+
+ CompletionQueueTag* op_tag = ctx_.GetCompletionOpTag();
+ cq_.TryPluck(op_tag, gpr_inf_future(GPR_CLOCK_REALTIME));
+
+ /* Ensure the cq_ is shutdown */
+ DummyTag ignored_tag;
+ GPR_ASSERT(cq_.Pluck(&ignored_tag) == false);
}
private:
@@ -494,7 +507,7 @@ int Server::AddListeningPort(const grpc::string& addr,
return port;
}
-bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) {
+void Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) {
GPR_ASSERT(!started_);
global_callbacks_->PreServerStart(this);
started_ = true;
@@ -530,8 +543,6 @@ bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) {
for (auto it = sync_req_mgrs_.begin(); it != sync_req_mgrs_.end(); it++) {
(*it)->Start();
}
-
- return true;
}
void Server::ShutdownInternal(gpr_timespec deadline) {
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index 3a408eb23e..afc9873c14 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -167,6 +167,10 @@ void ServerContext::BeginCompletionOp(Call* call) {
call->PerformOps(completion_op_);
}
+CompletionQueueTag* ServerContext::GetCompletionOpTag() {
+ return static_cast<CompletionQueueTag*>(completion_op_);
+}
+
void ServerContext::AddInitialMetadata(const grpc::string& key,
const grpc::string& value) {
initial_metadata_.insert(std::make_pair(key, value));