From a57ebbf953c55e16516f67899e9ee4c306065141 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 12 Jun 2014 14:31:07 +0200 Subject: [PATCH] Fix thinko with global zone sync refs #6254 --- lib/remote/apilistener-sync.cpp | 26 ++++++++++++++++++-------- lib/remote/zone.cpp | 10 ++++++++++ lib/remote/zone.hpp | 1 + 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/lib/remote/apilistener-sync.cpp b/lib/remote/apilistener-sync.cpp index 81ce77be9..9c561a956 100644 --- a/lib/remote/apilistener-sync.cpp +++ b/lib/remote/apilistener-sync.cpp @@ -126,12 +126,6 @@ void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const void ApiListener::SyncZoneDirs(void) const { BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects()) { - /* always sync global zone dirs */ - if (zone->GetGlobal()) { - SyncZoneDir(zone); - continue; - } - if (!IsConfigMaster(zone)) continue; @@ -158,8 +152,17 @@ void ApiListener::SendConfigUpdate(const ApiClient::Ptr& aclient) BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects()) { String zoneDir = zonesDir + "/" + zone->GetName(); - if (!zone->IsChildOf(azone) || !Utility::PathExists(zoneDir)) + if (!zone->IsChildOf(azone) && !zone->IsGlobal()) { + Log(LogNotice, "ApiListener", "Skipping sync for '" + zone->GetName() + "'. Not a child of zone '" + azone->GetName() + "'."); continue; + } + if (!Utility::PathExists(zoneDir)) { + Log(LogNotice, "ApiListener", "Ignoring sync for '" + zone->GetName() + "'. Zone directory '" + zoneDir + "' does not exist."); + continue; + } + + if (zone->IsGlobal()) + Log(LogInformation, "ApiListener", "Syncing global zone '" + zone->GetName() + "'."); configUpdate->Set(zone->GetName(), LoadConfigDir(zonesDir + "/" + zone->GetName())); } @@ -182,8 +185,15 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin& origin, const Dictio ApiListener::Ptr listener = ApiListener::GetInstance(); - if (!listener || !listener->GetAcceptConfig()) + if (!listener) { + Log(LogCritical, "ApiListener", "No instance available."); return Empty; + } + + if (!listener->GetAcceptConfig()) { + Log(LogWarning, "ApiListener", "Ignoring config update. '" + listener->GetName() + "' does not accept config."); + return Empty; + } Dictionary::Ptr update = params->Get("update"); diff --git a/lib/remote/zone.cpp b/lib/remote/zone.cpp index 2dbe706d8..e67e65119 100644 --- a/lib/remote/zone.cpp +++ b/lib/remote/zone.cpp @@ -81,6 +81,16 @@ bool Zone::IsChildOf(const Zone::Ptr& zone) return false; } +bool Zone::IsGlobal(void) +{ + Zone::Ptr zone = GetSelf(); + + if (!zone) + return false; + + return zone->GetGlobal(); +} + Zone::Ptr Zone::GetLocalZone(void) { Endpoint::Ptr local = Endpoint::GetLocalEndpoint(); diff --git a/lib/remote/zone.hpp b/lib/remote/zone.hpp index 7b484bdaf..1a17c5c18 100644 --- a/lib/remote/zone.hpp +++ b/lib/remote/zone.hpp @@ -41,6 +41,7 @@ public: bool CanAccessObject(const DynamicObject::Ptr& object); bool IsChildOf(const Zone::Ptr& zone); + bool IsGlobal(void); static Zone::Ptr GetLocalZone(void); }; -- 2.40.0