From 41c008bd6d4cc489fe340da7f372581b88019ccf Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Thu, 16 Oct 2025 11:52:30 +0300 Subject: [PATCH] [#4164] fixed data race in ping check --- src/hooks/dhcp/ping_check/ping_check_mgr.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hooks/dhcp/ping_check/ping_check_mgr.cc b/src/hooks/dhcp/ping_check/ping_check_mgr.cc index 08cae08693..9ad95b239b 100644 --- a/src/hooks/dhcp/ping_check/ping_check_mgr.cc +++ b/src/hooks/dhcp/ping_check/ping_check_mgr.cc @@ -203,6 +203,8 @@ PingCheckMgr::sendCompleted(const ICMPMsgPtr& echo, bool send_failed) { } try { + MultiThreadingLock lock(*mutex_); + if (!echo) { isc_throw(BadValue, "PingCheckMgr::sendCompleted() - echo is empty"); } @@ -230,7 +232,7 @@ PingCheckMgr::sendCompleted(const ICMPMsgPtr& echo, bool send_failed) { } // Update the expiration timer if necessary. - setNextExpiration(); + setNextExpirationInternal(); } catch (const std::exception& ex) { LOG_ERROR(ping_check_logger, PING_CHECK_MGR_SEND_COMPLETED_ERROR) .arg(ex.what()); @@ -244,6 +246,8 @@ PingCheckMgr::replyReceived(const ICMPMsgPtr& reply) { } try { + MultiThreadingLock lock(*mutex_); + if (!reply) { isc_throw(BadValue, "PingCheckMgr::replyReceived() - echo is empty"); } @@ -261,7 +265,7 @@ PingCheckMgr::replyReceived(const ICMPMsgPtr& reply) { return; } - setNextExpiration(); + setNextExpirationInternal(); } catch (const std::exception& ex) { LOG_ERROR(ping_check_logger, PING_CHECK_MGR_REPLY_RECEIVED_ERROR) .arg(ex.what()); -- 2.47.3