diff --git a/src/hooks/dhcp/high_availability/communication_state.cc b/src/hooks/dhcp/high_availability/communication_state.cc index d1fe6e1247..9989dffa24 100644 --- a/src/hooks/dhcp/high_availability/communication_state.cc +++ b/src/hooks/dhcp/high_availability/communication_state.cc @@ -112,7 +112,12 @@ CommunicationState::setPartnerScopes(ConstElementPtr new_scopes) { void CommunicationState::startHeartbeat(const long interval, const std::function& heartbeat_impl) { - startHeartbeatInternal(interval, heartbeat_impl); + if (MultiThreadingMgr::instance().getMode()) { + std::lock_guard lk(*mutex_); + startHeartbeatInternal(interval, heartbeat_impl); + } else { + startHeartbeatInternal(interval, heartbeat_impl); + } } void @@ -158,6 +163,16 @@ CommunicationState::startHeartbeatInternal(const long interval, void CommunicationState::stopHeartbeat() { + if (MultiThreadingMgr::instance().getMode()) { + std::lock_guard lk(*mutex_); + stopHeartbeatInternal(); + } else { + stopHeartbeatInternal(); + } +} + +void +CommunicationState::stopHeartbeatInternal() { if (timer_) { timer_->cancel(); timer_.reset(); diff --git a/src/hooks/dhcp/high_availability/communication_state.h b/src/hooks/dhcp/high_availability/communication_state.h index b78d192b62..43445eaee5 100644 --- a/src/hooks/dhcp/high_availability/communication_state.h +++ b/src/hooks/dhcp/high_availability/communication_state.h @@ -131,6 +131,9 @@ public: void startHeartbeat(const long interval, const std::function& heartbeat_impl); + /// @brief Stops recurring heartbeat. + void stopHeartbeat(); + protected: /// @brief Starts recurring heartbeat. @@ -141,10 +144,10 @@ protected: void startHeartbeatInternal(const long interval = 0, const std::function& heartbeat_impl = 0); -public: - /// @brief Stops recurring heartbeat. - void stopHeartbeat(); + void stopHeartbeatInternal(); + +public: /// @brief Checks if recurring heartbeat is running. /// diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc index 819e80f4e8..c5e29f273f 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc @@ -513,7 +513,7 @@ MySqlConfigBackendImpl::getOptionDefs(const int index, void MySqlConfigBackendImpl::createUpdateOptionDef(const db::ServerSelector& server_selector, const OptionDefinitionPtr& option_def, - const std::string& space, + const std::string& /*space*/, const int& /*get_option_def_code_space*/, const int& insert_option_def, const int& update_option_def, diff --git a/src/lib/testutils/dhcp_test_lib.sh.in b/src/lib/testutils/dhcp_test_lib.sh.in index 77711488df..9e18267175 100644 --- a/src/lib/testutils/dhcp_test_lib.sh.in +++ b/src/lib/testutils/dhcp_test_lib.sh.in @@ -440,8 +440,8 @@ get_pid() { _GET_PIDS_NUM=0 # If the PID file exists, get the PID and see if the process is alive. - if [ -e "${abs_pidfile_path}" ]; then - pid=$(cat "${abs_pidfile_path}") + pid=$(cat "${abs_pidfile_path}" || true) + if test -n "${pid}"; then if kill -0 "${pid}" > /dev/null 2>&1; then _GET_PID=${pid} _GET_PIDS_NUM=1