]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4164] fixed data race in ping check
authorRazvan Becheriu <razvan@isc.org>
Thu, 16 Oct 2025 08:52:30 +0000 (11:52 +0300)
committerAndrei Pavel <andrei@isc.org>
Mon, 27 Oct 2025 15:19:08 +0000 (17:19 +0200)
src/hooks/dhcp/ping_check/ping_check_mgr.cc

index 08cae08693fb93304b845af5ddfcafb0eb3bfcea..9ad95b239b55d82988389186dc761fcf250b881a 100644 (file)
@@ -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());