Skip to content

Commit c864911

Browse files
Henrik Triemymartin-ovh
authored andcommitted
Adapt #7786 to the new ConfigItem::CommitNewItems()
1 parent bba6a76 commit c864911

1 file changed

Lines changed: 37 additions & 8 deletions

File tree

lib/remote/apilistener-configsync.cpp

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,22 +443,51 @@ void ApiListener::SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient
443443
Log(LogInformation, "ApiListener")
444444
<< "Syncing runtime objects to endpoint '" << endpoint->GetName() << "'.";
445445

446+
std::set<Type::Ptr> types;
447+
std::set<Type::Ptr> completed_types;
448+
446449
for (const Type::Ptr& type : Type::GetAllTypes()) {
447-
auto *dtype = dynamic_cast<ConfigType *>(type.get());
450+
if (ConfigObject::TypeInstance->IsAssignableFrom(type))
451+
types.insert(type);
452+
}
453+
454+
while (types.size() != completed_types.size()) {
455+
for (const Type::Ptr& type : types) {
456+
if (completed_types.find(type) != completed_types.end())
457+
continue;
448458

449-
if (!dtype)
450-
continue;
459+
bool unresolved_dep = false;
451460

452-
for (const ConfigObject::Ptr& object : dtype->GetObjects()) {
453-
/* don't sync objects for non-matching parent-child zones */
454-
if (!azone->CanAccessObject(object))
461+
/* skip this type (for now) if there are unresolved load dependencies */
462+
for (auto pLoadDep : type->GetLoadDependencies()) {
463+
if (types.find(pLoadDep) != types.end() && completed_types.find(pLoadDep) == completed_types.end()) {
464+
unresolved_dep = true;
465+
break;
466+
}
467+
}
468+
469+
if (unresolved_dep)
455470
continue;
456471

457-
/* send the config object to the connected client */
458-
UpdateConfigObject(object, nullptr, aclient);
472+
auto *dtype = dynamic_cast<ConfigType *>(type.get());
473+
if (!dtype)
474+
continue;
475+
476+
for (const ConfigObject::Ptr& object : dtype->GetObjects()) {
477+
/* don't sync objects for non-matching parent-child zones */
478+
if (!azone->CanAccessObject(object))
479+
continue;
480+
481+
/* send the config object to the connected client */
482+
UpdateConfigObject(object, nullptr, aclient);
483+
}
484+
485+
completed_types.insert(type);
486+
459487
}
460488
}
461489

490+
462491
Log(LogInformation, "ApiListener")
463492
<< "Finished syncing runtime objects to endpoint '" << endpoint->GetName() << "'.";
464493
}

0 commit comments

Comments
 (0)