From 8f72f281801a878f84cc63765425b6243e168c39 Mon Sep 17 00:00:00 2001 From: Zhang Qinghua Date: Mon, 14 Sep 2020 11:10:42 +0800 Subject: [PATCH] Remove the timeout function in kernel build client. --- .../ccsrc/backend/session/kernel_build_client.h | 2 -- mindspore/ccsrc/common/duplex_pipe.cc | 14 +------------- mindspore/ccsrc/common/duplex_pipe.h | 5 ++--- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/mindspore/ccsrc/backend/session/kernel_build_client.h b/mindspore/ccsrc/backend/session/kernel_build_client.h index b91500d449..8e3c639b17 100644 --- a/mindspore/ccsrc/backend/session/kernel_build_client.h +++ b/mindspore/ccsrc/backend/session/kernel_build_client.h @@ -58,8 +58,6 @@ class KernelBuildClient { if (!init_) { // Exception's thrown if open failed if (dp_->Open({GetEnv(), GetScript()}, true) != -1) { - dp_->SetTimeOutSeconds(kTimeOutSeconds); - dp_->SetTimeOutCallback(std::make_shared>([this]() { Close(); })); dp_->SetFinalizeCallback(std::make_shared>([this]() { Close(); })); init_ = true; } diff --git a/mindspore/ccsrc/common/duplex_pipe.cc b/mindspore/ccsrc/common/duplex_pipe.cc index 811d11fe75..c2f53d574c 100644 --- a/mindspore/ccsrc/common/duplex_pipe.cc +++ b/mindspore/ccsrc/common/duplex_pipe.cc @@ -152,7 +152,7 @@ void DuplexPipe::Close() { DuplexPipe::SignalHandler::SignalHandler(std::shared_ptr dp, pid_t pid) { dp_ = dp; child_pid_ = pid; - signal(SIGCHLD, SigChildHandler); + signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SigPipeHandler); } @@ -178,16 +178,4 @@ void DuplexPipe::SignalHandler::SigPipeHandler(int sig) { dp_->NotifyFinalize(); } } - -void DuplexPipe::SignalHandler::SigChildHandler(int sig) { - DP_INFO << "Signal: " << sig << ", child_pid_: " << child_pid_; - int status; - auto pid = waitpid(child_pid_, &status, WNOHANG | WUNTRACED); - if (WIFEXITED(status)) { // Normal exit - DP_INFO << "Child exited, status: " << WEXITSTATUS(status) << ", pid: " << pid << ", dp: " << dp_; - if (pid > 0 && dp_ != nullptr) { // It's child_pid_ - dp_->NotifyFinalize(); - } - } -} } // namespace mindspore diff --git a/mindspore/ccsrc/common/duplex_pipe.h b/mindspore/ccsrc/common/duplex_pipe.h index e6af4b89d6..d99c2906ea 100644 --- a/mindspore/ccsrc/common/duplex_pipe.h +++ b/mindspore/ccsrc/common/duplex_pipe.h @@ -61,12 +61,12 @@ class DuplexPipe : public std::enable_shared_from_this { private: void SetTimeOut() { - if (signal_handler_ != nullptr) { + if (time_out_callback_ != nullptr && signal_handler_ != nullptr) { signal_handler_->SetAlarm(time_out_secs_); } } void CancelTimeOut() { - if (signal_handler_ != nullptr) { + if (time_out_callback_ != nullptr && signal_handler_ != nullptr) { signal_handler_->CancelAlarm(); } } @@ -118,7 +118,6 @@ class DuplexPipe : public std::enable_shared_from_this { private: static void SigAlarmHandler(int sig); static void SigPipeHandler(int sig); - static void SigChildHandler(int sig); inline static std::shared_ptr dp_; inline static pid_t child_pid_;