[#4248] Added main thread id to logs

This commit is contained in:
Francis Dupont
2025-12-08 22:59:11 +01:00
parent 7ac56a17ce
commit 397cb7a2dc
3 changed files with 14 additions and 11 deletions

Binary file not shown.

View 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.

View 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();