Skip to content

Commit 9905e9a

Browse files
authored
Merge pull request #10389 from Icinga/zone-endpoint-order
Zone#GetEndpoints(): return endpoints in the specified order, not randomly🎲
2 parents 5f2ee6e + a943c45 commit 9905e9a

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

lib/icinga/apiactions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object, cons
931931
for (const Zone::Ptr& zone : ConfigType::GetObjectsByType<Zone>()) {
932932
/* Fetch immediate child zone members */
933933
if (zone->GetParent() == localZone && zone->CanAccessObject(endpointPtr->GetZone())) {
934-
std::set<Endpoint::Ptr> endpoints = zone->GetEndpoints();
934+
auto endpoints (zone->GetEndpoints());
935935

936936
for (const Endpoint::Ptr& childEndpoint : endpoints) {
937937
if (!(childEndpoint->GetCapabilities() & (uint_fast64_t)ApiCapabilities::ExecuteArbitraryCommand)) {

lib/icinga/clusterevents.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ Value ClusterEvents::ExecuteCommandAPIHandler(const MessageOrigin::Ptr& origin,
966966
for (const Zone::Ptr &zone : ConfigType::GetObjectsByType<Zone>()) {
967967
/* Fetch immediate child zone members */
968968
if (zone->GetParent() == localZone && zone->CanAccessObject(endpointZone)) {
969-
std::set<Endpoint::Ptr> endpoints = zone->GetEndpoints();
969+
auto endpoints (zone->GetEndpoints());
970970

971971
for (const Endpoint::Ptr &childEndpoint : endpoints) {
972972
if (!(childEndpoint->GetCapabilities() & (uint_fast64_t)ApiCapabilities::ExecuteArbitraryCommand)) {

lib/livestatus/zonestable.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ Value ZonesTable::EndpointsAccessor(const Value& row)
7070
if (!zone)
7171
return Empty;
7272

73-
std::set<Endpoint::Ptr> endpoints = zone->GetEndpoints();
74-
73+
auto endpoints (zone->GetEndpoints());
7574
ArrayData result;
7675

7776
for (const Endpoint::Ptr& endpoint : endpoints) {

lib/remote/zone.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ Zone::Ptr Zone::GetParent() const
5151
return m_Parent;
5252
}
5353

54-
std::set<Endpoint::Ptr> Zone::GetEndpoints() const
54+
std::vector<Endpoint::Ptr> Zone::GetEndpoints() const
5555
{
56-
std::set<Endpoint::Ptr> result;
57-
56+
std::vector<Endpoint::Ptr> result;
5857
Array::Ptr endpoints = GetEndpointsRaw();
5958

6059
if (endpoints) {
@@ -66,7 +65,7 @@ std::set<Endpoint::Ptr> Zone::GetEndpoints() const
6665
if (!endpoint)
6766
continue;
6867

69-
result.insert(endpoint);
68+
result.emplace_back(std::move(endpoint));
7069
}
7170
}
7271

lib/remote/zone.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Zone final : public ObjectImpl<Zone>
2222
void OnAllConfigLoaded() override;
2323

2424
Zone::Ptr GetParent() const;
25-
std::set<Endpoint::Ptr> GetEndpoints() const;
25+
std::vector<Endpoint::Ptr> GetEndpoints() const;
2626
std::vector<Zone::Ptr> GetAllParentsRaw() const;
2727
Array::Ptr GetAllParents() const override;
2828

0 commit comments

Comments
 (0)