Skip to content

Commit 9583dc3

Browse files
authored
Merge pull request #5 from typhoonzero/fix_server_shutdown
Fix server shutdown
2 parents e727cdb + 52439d9 commit 9583dc3

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

paddle/fluid/operators/detail/grpc_server.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ void AsyncGRPCServer::ShutdownQueue() {
174174
std::unique_lock<std::mutex> lock(cq_mutex_);
175175
cq_send_->Shutdown();
176176
cq_get_->Shutdown();
177-
is_shut_down_ = true;
178177
}
179178

180179
// This URL explains why shutdown is complicate:
181180
void AsyncGRPCServer::ShutDown() {
182-
server_->Shutdown();
181+
is_shut_down_ = true;
183182
ShutdownQueue();
183+
server_->Shutdown();
184184
}
185185

186186
void AsyncGRPCServer::TryToRegisterNewSendOne() {
@@ -213,14 +213,14 @@ void AsyncGRPCServer::HandleRequest(::grpc::ServerCompletionQueue* cq,
213213
bool ok = false;
214214
while (true) {
215215
if (!cq->Next(&tag, &ok)) {
216-
LOG(INFO) << cq_name << " get CompletionQueue shutdown!";
216+
LOG(INFO) << cq_name << " CompletionQueue shutdown!";
217217
break;
218218
}
219219

220220
PADDLE_ENFORCE(tag);
221221
// FIXME(typhoonzero): de-couple the barriers with recv_op
222-
if (cq_name == "cq_get") WaitCond(1);
223-
if (cq_name == "cq_send") WaitCond(0);
222+
if (!is_shut_down_ && cq_name == "cq_get") WaitCond(1);
223+
if (!is_shut_down_ && cq_name == "cq_send") WaitCond(0);
224224

225225
RequestBase* base = (RequestBase*)tag;
226226
// reference:

paddle/fluid/operators/listen_and_serv_op.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class ListenAndServOp : public framework::OperatorBase {
7070

7171
void Stop() override {
7272
rpc_service_->Push(LISTEN_TERMINATE_MESSAGE);
73-
rpc_service_->ShutDown();
7473
server_thread_->join();
7574
}
7675

0 commit comments

Comments
 (0)