]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4248] Added main thread id to logs
authorFrancis Dupont <fdupont@isc.org>
Mon, 8 Dec 2025 21:59:11 +0000 (22:59 +0100)
committerFrancis Dupont <fdupont@isc.org>
Tue, 9 Dec 2025 22:15:38 +0000 (23:15 +0100)
src/lib/dhcp/dhcp_messages.cc
src/lib/dhcp/dhcp_messages.mes
src/lib/dhcp/iface_mgr.cc

index 7f6014e4e6a2e1c92222061d207016d83c1eb588..46c60eb526caa7a5aeb7292c7447873615f2635e 100644 (file)
@@ -17,9 +17,9 @@ extern const isc::log::MessageID DHCP_DELETE_EXTERNAL_SOCKET = "DHCP_DELETE_EXTE
 namespace {
 
 const char* values[] = {
-    "DHCP_ADD_EXTERNAL_SOCKET", "Attempted to register external socket %1 from different thread %2",
-    "DHCP_DELETE_ALL_EXTERNAL_SOCKETS", "Attempted to unregister external sockets from different thread %1",
-    "DHCP_DELETE_EXTERNAL_SOCKET", "Attempted to unregister external socket %1 from different thread %2",
+    "DHCP_ADD_EXTERNAL_SOCKET", "Attempted to register external socket %1 from different thread %2 than main thread %3",
+    "DHCP_DELETE_ALL_EXTERNAL_SOCKETS", "Attempted to unregister external sockets from different thread %1 than main thread %2",
+    "DHCP_DELETE_EXTERNAL_SOCKET", "Attempted to unregister external socket %1 from different thread %2 than main thread %3",
     NULL
 };
 
index 44c90424cfce1ccefc9f979988f15a85f415690d..f954c2d4be2e49af0392219c2696846b1897fb15 100644 (file)
@@ -6,20 +6,20 @@
 
 $NAMESPACE isc::dhcp
 
-% DHCP_ADD_EXTERNAL_SOCKET Attempted to register external socket %1 from different thread %2
+% DHCP_ADD_EXTERNAL_SOCKET Attempted to register external socket %1 from different thread %2 than main thread %3
 This error message indicates that a different thread than the main thread has
 registered an external socket. This is a programming error and should be fixed.
 Only the main thread is allowed to perform operations on the external sockets.
-The file descritptor and the respective thread id are included in the message.
+The file descritptor and the respective thread ids are included in the message.
 
-% DHCP_DELETE_ALL_EXTERNAL_SOCKETS Attempted to unregister external sockets from different thread %1
+% DHCP_DELETE_ALL_EXTERNAL_SOCKETS Attempted to unregister external sockets from different thread %1 than main thread %2
 This error message indicates that a different thread than the main thread has
 deleted all external sockets. This is a programming error and should be fixed.
 Only the main thread is allowed to perform operations on the external sockets.
-The respective thread id is included in the message.
+The respective thread ids are included in the message.
 
-% DHCP_DELETE_EXTERNAL_SOCKET Attempted to unregister external socket %1 from different thread %2
+% DHCP_DELETE_EXTERNAL_SOCKET Attempted to unregister external socket %1 from different thread %2 than main thread %3
 This error message indicates that a different thread than the main thread has
 unregistered an external socket. This is a programming error and should be fixed.
 Only the main thread is allowed to perform operations on the external sockets.
-The file descritptor and the respective thread id are included in the message.
+The file descritptor and the respective thread ids are included in the message.
index c817cc54692fb82e4b98d288cc9900a02c1ba3b1..a2ff19bdb178ecfd84460a2a82eecf59ef9e0ef9 100644 (file)
@@ -336,8 +336,9 @@ IfaceMgr::addExternalSocket(int socketfd, SocketCallback callback) {
     }
     if (check_thread_id_ && std::this_thread::get_id() != id_) {
         LOG_ERROR(dhcp_logger, DHCP_ADD_EXTERNAL_SOCKET)
-                .arg(socketfd)
-                .arg(std::this_thread::get_id());
+            .arg(socketfd)
+            .arg(std::this_thread::get_id())
+            .arg(id_);
     }
     std::lock_guard<std::mutex> lock(callbacks_mutex_);
     for (SocketCallbackInfo& s : callbacks_) {
@@ -367,8 +368,9 @@ void
 IfaceMgr::deleteExternalSocketInternal(int socketfd) {
     if (check_thread_id_ && std::this_thread::get_id() != id_) {
         LOG_ERROR(dhcp_logger, DHCP_DELETE_EXTERNAL_SOCKET)
-                .arg(socketfd)
-                .arg(std::this_thread::get_id());
+            .arg(socketfd)
+            .arg(std::this_thread::get_id())
+            .arg(id_);
     }
     for (SocketCallbackInfoContainer::iterator s = callbacks_.begin();
          s != callbacks_.end(); ++s) {
@@ -407,7 +409,8 @@ void
 IfaceMgr::deleteAllExternalSockets() {
     if (check_thread_id_ && std::this_thread::get_id() != id_) {
         LOG_ERROR(dhcp_logger, DHCP_DELETE_ALL_EXTERNAL_SOCKETS)
-                .arg(std::this_thread::get_id());
+            .arg(std::this_thread::get_id())
+            .arg(id_);
     }
     std::lock_guard<std::mutex> lock(callbacks_mutex_);
     callbacks_.clear();