mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-03 15:35:17 +00:00
[#1627] make CommunicationState::startHeartbeat thread safe
This commit is contained in:
@@ -112,7 +112,12 @@ CommunicationState::setPartnerScopes(ConstElementPtr new_scopes) {
|
||||
void
|
||||
CommunicationState::startHeartbeat(const long interval,
|
||||
const std::function<void()>& heartbeat_impl) {
|
||||
startHeartbeatInternal(interval, heartbeat_impl);
|
||||
if (MultiThreadingMgr::instance().getMode()) {
|
||||
std::lock_guard<std::mutex> 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<std::mutex> lk(*mutex_);
|
||||
stopHeartbeatInternal();
|
||||
} else {
|
||||
stopHeartbeatInternal();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CommunicationState::stopHeartbeatInternal() {
|
||||
if (timer_) {
|
||||
timer_->cancel();
|
||||
timer_.reset();
|
||||
|
@@ -131,6 +131,9 @@ public:
|
||||
void startHeartbeat(const long interval,
|
||||
const std::function<void()>& 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<void()>& heartbeat_impl = 0);
|
||||
|
||||
public:
|
||||
|
||||
/// @brief Stops recurring heartbeat.
|
||||
void stopHeartbeat();
|
||||
void stopHeartbeatInternal();
|
||||
|
||||
public:
|
||||
|
||||
/// @brief Checks if recurring heartbeat is running.
|
||||
///
|
||||
|
@@ -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,
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user