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

Fix some shutdown errors related to CQ/join ordering

parent aa8bbeb6
No related branches found
No related tags found
No related merge requests found
...@@ -189,14 +189,7 @@ class AsyncClient : public ClientImpl<StubType, RequestType> { ...@@ -189,14 +189,7 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
} }
} }
virtual ~AsyncClient() { virtual ~AsyncClient() {
for (auto cq = cli_cqs_.begin(); cq != cli_cqs_.end(); cq++) { FinalShutdownCQs();
(*cq)->Shutdown();
void* got_tag;
bool ok;
while ((*cq)->Next(&got_tag, &ok)) {
delete ClientRpcContext::detag(got_tag);
}
}
} }
bool ThreadFunc(HistogramEntry* entry, bool ThreadFunc(HistogramEntry* entry,
...@@ -216,14 +209,29 @@ class AsyncClient : public ClientImpl<StubType, RequestType> { ...@@ -216,14 +209,29 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
delete ctx; delete ctx;
} }
return true; return true;
} else { // queue is shutting down } else { // queue is shutting down, so we must be done
return false; return true;
} }
} }
protected: protected:
const int num_async_threads_; const int num_async_threads_;
void ShutdownCQs() {
for (auto cq = cli_cqs_.begin(); cq != cli_cqs_.end(); cq++) {
(*cq)->Shutdown();
}
}
void FinalShutdownCQs() {
for (auto cq = cli_cqs_.begin(); cq != cli_cqs_.end(); cq++) {
void* got_tag;
bool ok;
while ((*cq)->Next(&got_tag, &ok)) {
delete ClientRpcContext::detag(got_tag);
}
}
}
private: private:
int NumThreads(const ClientConfig& config) { int NumThreads(const ClientConfig& config) {
int num_threads = config.async_client_threads(); int num_threads = config.async_client_threads();
...@@ -251,7 +259,10 @@ class AsyncUnaryClient GRPC_FINAL ...@@ -251,7 +259,10 @@ class AsyncUnaryClient GRPC_FINAL
config, SetupCtx, BenchmarkStubCreator) { config, SetupCtx, BenchmarkStubCreator) {
StartThreads(num_async_threads_); StartThreads(num_async_threads_);
} }
~AsyncUnaryClient() GRPC_OVERRIDE { EndThreads(); } ~AsyncUnaryClient() GRPC_OVERRIDE {
ShutdownCQs();
EndThreads();
}
private: private:
static void CheckDone(grpc::Status s, SimpleResponse* response) {} static void CheckDone(grpc::Status s, SimpleResponse* response) {}
...@@ -380,7 +391,10 @@ class AsyncStreamingClient GRPC_FINAL ...@@ -380,7 +391,10 @@ class AsyncStreamingClient GRPC_FINAL
StartThreads(num_async_threads_); StartThreads(num_async_threads_);
} }
~AsyncStreamingClient() GRPC_OVERRIDE { EndThreads(); } ~AsyncStreamingClient() GRPC_OVERRIDE {
ShutdownCQs();
EndThreads();
}
private: private:
static void CheckDone(grpc::Status s, SimpleResponse* response) {} static void CheckDone(grpc::Status s, SimpleResponse* response) {}
...@@ -516,7 +530,10 @@ class GenericAsyncStreamingClient GRPC_FINAL ...@@ -516,7 +530,10 @@ class GenericAsyncStreamingClient GRPC_FINAL
StartThreads(num_async_threads_); StartThreads(num_async_threads_);
} }
~GenericAsyncStreamingClient() GRPC_OVERRIDE { EndThreads(); } ~GenericAsyncStreamingClient() GRPC_OVERRIDE {
ShutdownCQs();
EndThreads();
}
private: private:
static void CheckDone(grpc::Status s, ByteBuffer* response) {} static void CheckDone(grpc::Status s, ByteBuffer* response) {}
......
...@@ -128,6 +128,7 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { ...@@ -128,6 +128,7 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service {
ScopedProfile profile("qps_client.prof", false); ScopedProfile profile("qps_client.prof", false);
Status ret = RunClientBody(ctx, stream); Status ret = RunClientBody(ctx, stream);
gpr_log(GPR_INFO, "RunClient: Returning");
return ret; return ret;
} }
...@@ -141,6 +142,7 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { ...@@ -141,6 +142,7 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service {
ScopedProfile profile("qps_server.prof", false); ScopedProfile profile("qps_server.prof", false);
Status ret = RunServerBody(ctx, stream); Status ret = RunServerBody(ctx, stream);
gpr_log(GPR_INFO, "RunServer: Returning");
return ret; return ret;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment