ApiListener#RelayMessageOne(): log to which Endpoint messages are relayed

if they're for our parent Zone.
This commit is contained in:
Alexander A. Klimov 2025-04-03 10:30:12 +02:00 committed by Julian Brost
parent fc70825cb2
commit e8da951c1f
2 changed files with 18 additions and 1 deletions

View File

@ -1226,11 +1226,12 @@ bool ApiListener::RelayMessageOne(const Zone::Ptr& targetZone, const MessageOrig
ASSERT(targetZone);
Zone::Ptr localZone = Zone::GetLocalZone();
auto parentZone (localZone->GetParent());
/* only relay the message to a) the same local zone, b) the parent zone and c) direct child zones. Exception is a global zone. */
if (!targetZone->GetGlobal() &&
targetZone != localZone &&
targetZone != localZone->GetParent() &&
targetZone != parentZone &&
targetZone->GetParent() != localZone) {
return true;
}
@ -1309,12 +1310,26 @@ bool ApiListener::RelayMessageOne(const Zone::Ptr& targetZone, const MessageOrig
bool isMaster = (currentZoneMaster == localEndpoint);
if (!isMaster && targetEndpoint != currentZoneMaster) {
if (currentTargetZone == parentZone) {
if (m_CurrentParentEndpoint.exchange(currentZoneMaster.get()) != currentZoneMaster.get()) {
Log(LogInformation, "ApiListener") << "Relaying messages for parent Zone '"
<< parentZone->GetName() << "' to Endpoint '" << currentZoneMaster->GetName() << "'";
}
}
skippedEndpoints.push_back(targetEndpoint);
continue;
}
relayed = true;
if (currentTargetZone == parentZone) {
if (m_CurrentParentEndpoint.exchange(targetEndpoint.get()) != targetEndpoint.get()) {
Log(LogInformation, "ApiListener") << "Relaying messages for parent Zone '"
<< parentZone->GetName() << "' to Endpoint '" << targetEndpoint->GetName() << "'";
}
}
SyncSendMessage(targetEndpoint, message);
}

View File

@ -8,6 +8,7 @@
#include "remote/httpserverconnection.hpp"
#include "remote/endpoint.hpp"
#include "remote/messageorigin.hpp"
#include "base/atomic.hpp"
#include "base/configobject.hpp"
#include "base/process.hpp"
#include "base/shared.hpp"
@ -177,6 +178,7 @@ private:
Timer::Ptr m_RenewOwnCertTimer;
Endpoint::Ptr m_LocalEndpoint;
Atomic<Endpoint*> m_CurrentParentEndpoint {nullptr};
static ApiListener::Ptr m_Instance;
static std::atomic<bool> m_UpdatedObjectAuthority;