Skip to content

Commit dd082ef

Browse files
committed
Bugfix: remove log in child process in case of deadlock in logger after fork.
Signed-off-by: Li Junlin <[email protected]>
1 parent a649dff commit dd082ef

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/Craned/CgroupManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,10 @@ bool CgroupManager::ReleaseCgroup(uint32_t task_id, uid_t uid) {
450450
task_id_set_ptr->erase(task_id);
451451
if (task_id_set_ptr->empty()) {
452452
// In case of destroy a locked lock
453-
task_id_set_empty=true;
453+
task_id_set_empty = true;
454454
}
455455
}
456-
if (task_id_set_empty)uid_task_ids_map_ptr->erase(uid);
456+
if (task_id_set_empty) uid_task_ids_map_ptr->erase(uid);
457457

458458
return true;
459459
}

src/Craned/CtldClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ CtldClient::~CtldClient() {
2424
m_thread_stop_ = true;
2525

2626
CRANE_TRACE("CtldClient is ending. Waiting for the thread to finish.");
27-
if(m_async_send_thread_.joinable())m_async_send_thread_.join();
27+
if (m_async_send_thread_.joinable()) m_async_send_thread_.join();
2828
}
2929

3030
void CtldClient::InitChannelAndStub(const std::string& server_address) {

src/Craned/TaskManager.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,8 @@ CraneErr TaskManager::SpawnProcessInInstance_(TaskInstance* instance,
714714
const std::string& cwd = instance->task.cwd();
715715
rc = chdir(cwd.c_str());
716716
if (rc == -1) {
717-
CRANE_ERROR("[Child Process] Error: chdir to {}. {}", cwd.c_str(),
718-
strerror(errno));
717+
// CRANE_ERROR("[Child Process] Error: chdir to {}. {}", cwd.c_str(),
718+
// strerror(errno));
719719
std::abort();
720720
}
721721

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

737737
ok = ParseDelimitedFromZeroCopyStream(&msg, &istream, nullptr);
738738
if (!ok || !msg.ok()) {
739-
if (!ok) {
740-
int err = istream.GetErrno();
741-
CRANE_ERROR("Failed to read socket from parent: {}", strerror(err));
742-
}
739+
// if (!ok) {
740+
// int err = istream.GetErrno();
741+
// CRANE_ERROR("Failed to read socket from parent: {}", strerror(err));
742+
// }
743743

744-
if (!msg.ok())
745-
CRANE_ERROR("Parent process ask not to start the subprocess.");
744+
// if (!msg.ok())
745+
// CRANE_ERROR("Parent process ask not to start the subprocess.");
746746

747747
std::abort();
748748
}
@@ -758,8 +758,8 @@ CraneErr TaskManager::SpawnProcessInInstance_(TaskInstance* instance,
758758
stdout_fd =
759759
open(stdout_file_path.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644);
760760
if (stdout_fd == -1) {
761-
CRANE_ERROR("[Child Process] Error: open {}. {}", stdout_file_path,
762-
strerror(errno));
761+
// CRANE_ERROR("[Child Process] Error: open {}. {}", stdout_file_path,
762+
// strerror(errno));
763763
std::abort();
764764
}
765765
dup2(stdout_fd, 1);
@@ -770,8 +770,8 @@ CraneErr TaskManager::SpawnProcessInInstance_(TaskInstance* instance,
770770
stderr_fd =
771771
open(stderr_file_path.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644);
772772
if (stderr_fd == -1) {
773-
CRANE_ERROR("[Child Process] Error: open {}. {}", stderr_file_path,
774-
strerror(errno));
773+
// CRANE_ERROR("[Child Process] Error: open {}. {}", stderr_file_path,
774+
// strerror(errno));
775775
std::abort();
776776
}
777777
dup2(stderr_fd, 2); // stderr -> error file
@@ -795,7 +795,7 @@ CraneErr TaskManager::SpawnProcessInInstance_(TaskInstance* instance,
795795
ok = SerializeDelimitedToZeroCopyStream(child_process_ready, &ostream);
796796
ok &= ostream.Flush();
797797
if (!ok) {
798-
CRANE_ERROR("[Child Process] Error: Failed to flush.");
798+
// CRANE_ERROR("[Child Process] Error: Failed to flush.");
799799
std::abort();
800800
}
801801

0 commit comments

Comments
 (0)