Create servers in configuration order

As we know servers don't have dependencies, we can construct them in
configuration file order.
This commit is contained in:
Markus Mäkelä 2018-08-01 14:24:56 +03:00
parent f68da38b32
commit a0b0f7993e
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -1482,12 +1482,30 @@ process_config_context(CONFIG_CONTEXT *context)
}
}
if (resolve_dependencies(objects))
int error_count = 0;
/**
* Build the servers first to keep them in configuration file order. As
* servers can't have references, this is safe to do as the first step.
*/
for (CONFIG_CONTEXT* obj : objects)
{
std::string type = config_get_string(obj->parameters, CN_TYPE);
ss_dassert(!type.empty());
if (type == CN_SERVER)
{
error_count += create_new_server(obj);
}
}
// Resolve any remaining dependencies between the objects
if (resolve_dependencies(objects) || error_count)
{
return false;
}
int error_count = 0;
std::set<std::string> monitored_servers;
/**
* Process the data and create the services and servers defined
@ -1502,10 +1520,6 @@ process_config_context(CONFIG_CONTEXT *context)
{
error_count += create_new_service(obj);
}
else if (type == CN_SERVER)
{
error_count += create_new_server(obj);
}
else if (type == CN_FILTER)
{
error_count += create_new_filter(obj);