@@ -443,22 +443,52 @@ 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 (const String& loadDep : type->GetLoadDependencies ()) {
463+ Type::Ptr pLoadDep = Type::GetByName (loadDep);
464+ if (types.find (pLoadDep) != types.end () && completed_types.find (pLoadDep) == completed_types.end ()) {
465+ unresolved_dep = true ;
466+ break ;
467+ }
468+ }
469+
470+ if (unresolved_dep)
455471 continue ;
456472
457- /* send the config object to the connected client */
458- UpdateConfigObject (object, nullptr , aclient);
473+ auto *dtype = dynamic_cast <ConfigType *>(type.get ());
474+ if (!dtype)
475+ continue ;
476+
477+ for (const ConfigObject::Ptr& object : dtype->GetObjects ()) {
478+ /* don't sync objects for non-matching parent-child zones */
479+ if (!azone->CanAccessObject (object))
480+ continue ;
481+
482+ /* send the config object to the connected client */
483+ UpdateConfigObject (object, nullptr , aclient);
484+ }
485+
486+ completed_types.insert (type);
487+
459488 }
460489 }
461490
491+
462492 Log (LogInformation, " ApiListener" )
463493 << " Finished syncing runtime objects to endpoint '" << endpoint->GetName () << " '." ;
464494}
0 commit comments