Skip to content

Commit

Permalink
Bugfix: remove log in child process in case of deadlock in logger aft…
Browse files Browse the repository at this point in the history
…er fork.

Signed-off-by: Li Junlin <[email protected]>
  • Loading branch information
L-Xiafeng committed Nov 12, 2024
1 parent a649dff commit dd082ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/Craned/CgroupManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,10 @@ bool CgroupManager::ReleaseCgroup(uint32_t task_id, uid_t uid) {
task_id_set_ptr->erase(task_id);
if (task_id_set_ptr->empty()) {
// In case of destroy a locked lock
task_id_set_empty=true;
task_id_set_empty = true;
}
}
if (task_id_set_empty)uid_task_ids_map_ptr->erase(uid);
if (task_id_set_empty) uid_task_ids_map_ptr->erase(uid);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Craned/CtldClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CtldClient::~CtldClient() {
m_thread_stop_ = true;

CRANE_TRACE("CtldClient is ending. Waiting for the thread to finish.");
if(m_async_send_thread_.joinable())m_async_send_thread_.join();
if (m_async_send_thread_.joinable()) m_async_send_thread_.join();
}

void CtldClient::InitChannelAndStub(const std::string& server_address) {
Expand Down
26 changes: 13 additions & 13 deletions src/Craned/TaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,8 @@ CraneErr TaskManager::SpawnProcessInInstance_(TaskInstance* instance,
const std::string& cwd = instance->task.cwd();
rc = chdir(cwd.c_str());
if (rc == -1) {
CRANE_ERROR("[Child Process] Error: chdir to {}. {}", cwd.c_str(),
strerror(errno));
// CRANE_ERROR("[Child Process] Error: chdir to {}. {}", cwd.c_str(),
// strerror(errno));
std::abort();
}

Expand All @@ -736,13 +736,13 @@ CraneErr TaskManager::SpawnProcessInInstance_(TaskInstance* instance,

ok = ParseDelimitedFromZeroCopyStream(&msg, &istream, nullptr);
if (!ok || !msg.ok()) {
if (!ok) {
int err = istream.GetErrno();
CRANE_ERROR("Failed to read socket from parent: {}", strerror(err));
}
// if (!ok) {
// int err = istream.GetErrno();
// CRANE_ERROR("Failed to read socket from parent: {}", strerror(err));
// }

if (!msg.ok())
CRANE_ERROR("Parent process ask not to start the subprocess.");
// if (!msg.ok())
// CRANE_ERROR("Parent process ask not to start the subprocess.");

std::abort();
}
Expand All @@ -758,8 +758,8 @@ CraneErr TaskManager::SpawnProcessInInstance_(TaskInstance* instance,
stdout_fd =
open(stdout_file_path.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644);
if (stdout_fd == -1) {
CRANE_ERROR("[Child Process] Error: open {}. {}", stdout_file_path,
strerror(errno));
// CRANE_ERROR("[Child Process] Error: open {}. {}", stdout_file_path,
// strerror(errno));
std::abort();
}
dup2(stdout_fd, 1);
Expand All @@ -770,8 +770,8 @@ CraneErr TaskManager::SpawnProcessInInstance_(TaskInstance* instance,
stderr_fd =
open(stderr_file_path.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644);
if (stderr_fd == -1) {
CRANE_ERROR("[Child Process] Error: open {}. {}", stderr_file_path,
strerror(errno));
// CRANE_ERROR("[Child Process] Error: open {}. {}", stderr_file_path,
// strerror(errno));
std::abort();
}
dup2(stderr_fd, 2); // stderr -> error file
Expand All @@ -795,7 +795,7 @@ CraneErr TaskManager::SpawnProcessInInstance_(TaskInstance* instance,
ok = SerializeDelimitedToZeroCopyStream(child_process_ready, &ostream);
ok &= ostream.Flush();
if (!ok) {
CRANE_ERROR("[Child Process] Error: Failed to flush.");
// CRANE_ERROR("[Child Process] Error: Failed to flush.");
std::abort();
}

Expand Down

0 comments on commit dd082ef

Please sign in to comment.