Unverified Commit c4d07948 authored by David Boucher's avatar David Boucher Committed by GitHub
Browse files

fix(process_manager): deadlock removed. (#28)

parent a797f01c
===================
Centreon Clib 20.04
===================
*********
Bug fixes
*********
Deadlock removed
================
A possible deadlock was removed when a process is added and at the same time
a process is removed because in timeout.
......@@ -52,12 +52,14 @@ void process_manager::add(process* p) {
if (!p)
throw basic_error() << "invalid process: null pointer";
std::lock_guard<std::mutex> lock_process(p->_lock_process);
// We lock _lock_processes before to avoid deadlocks
std::lock_guard<std::mutex> lock(_lock_processes);
// Check if the process need to be managed.
std::lock_guard<std::mutex> lock_process(p->_lock_process);
if (p->_process == static_cast<pid_t>(-1))
throw basic_error() << "invalid process: not running";
std::lock_guard<std::mutex> lock(_lock_processes);
// Add pid process to use waitpid.
_processes_pid[p->_process] = p;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment