Browse Source

!6154 Remove the timeout function in kernel build client.

Merge pull request !6154 from 张清华/master2
tags/v1.0.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
759876f5bf
3 changed files with 3 additions and 18 deletions
  1. +0
    -2
      mindspore/ccsrc/backend/session/kernel_build_client.h
  2. +1
    -13
      mindspore/ccsrc/common/duplex_pipe.cc
  3. +2
    -3
      mindspore/ccsrc/common/duplex_pipe.h

+ 0
- 2
mindspore/ccsrc/backend/session/kernel_build_client.h View File

@@ -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<std::function<void()>>([this]() { Close(); }));
dp_->SetFinalizeCallback(std::make_shared<std::function<void()>>([this]() { Close(); }));
init_ = true;
}


+ 1
- 13
mindspore/ccsrc/common/duplex_pipe.cc View File

@@ -152,7 +152,7 @@ void DuplexPipe::Close() {
DuplexPipe::SignalHandler::SignalHandler(std::shared_ptr<DuplexPipe> 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

+ 2
- 3
mindspore/ccsrc/common/duplex_pipe.h View File

@@ -61,12 +61,12 @@ class DuplexPipe : public std::enable_shared_from_this<mindspore::DuplexPipe> {

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<mindspore::DuplexPipe> {
private:
static void SigAlarmHandler(int sig);
static void SigPipeHandler(int sig);
static void SigChildHandler(int sig);

inline static std::shared_ptr<DuplexPipe> dp_;
inline static pid_t child_pid_;


Loading…
Cancel
Save