mirror of
https://github.com/pissnet/pissircd.git
synced 2025-07-29 14:32:25 +01:00
Swap order of config_run_blocks() and config_test_blocks() since that
makes more sense when reading the source code.
This commit is contained in:
parent
9fef375d0a
commit
8e7eacadfe
1 changed files with 90 additions and 90 deletions
180
src/conf.c
180
src/conf.c
|
@ -2661,96 +2661,6 @@ static const char *config_run_priority_blocks[] =
|
|||
"class",
|
||||
};
|
||||
|
||||
int config_run_blocks(void)
|
||||
{
|
||||
ConfigEntry *ce;
|
||||
ConfigFile *cfptr;
|
||||
ConfigCommand *cc;
|
||||
int errors = 0;
|
||||
int i;
|
||||
Hook *h;
|
||||
ConfigItem_allow *allow;
|
||||
|
||||
/* Stage 1: first the priority blocks, in the order as specified
|
||||
* in config_run_priority_blocks[]
|
||||
*/
|
||||
for (i=0; i < ARRAY_SIZEOF(config_run_priority_blocks); i++)
|
||||
{
|
||||
const char *config_block = config_run_priority_blocks[i];
|
||||
cc = config_binary_search(config_block);
|
||||
if (!cc)
|
||||
abort(); /* internal fuckup */
|
||||
if (!strcmp(config_block, "secret"))
|
||||
continue; /* yeah special case, we already processed the run part in test for these */
|
||||
for (cfptr = conf; cfptr; cfptr = cfptr->next)
|
||||
{
|
||||
if (config_verbose > 1)
|
||||
config_status("Running %s", cfptr->filename);
|
||||
for (ce = cfptr->items; ce; ce = ce->next)
|
||||
{
|
||||
if (!strcmp(ce->name, config_block))
|
||||
{
|
||||
if (cc->conffunc(cfptr, ce) < 0)
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Stage 2: now all the other config blocks */
|
||||
for (cfptr = conf; cfptr; cfptr = cfptr->next)
|
||||
{
|
||||
if (config_verbose > 1)
|
||||
config_status("Running %s", cfptr->filename);
|
||||
for (ce = cfptr->items; ce; ce = ce->next)
|
||||
{
|
||||
char skip = 0;
|
||||
for (i=0; i < ARRAY_SIZEOF(config_run_priority_blocks); i++)
|
||||
{
|
||||
if (!strcmp(ce->name, config_run_priority_blocks[i]))
|
||||
{
|
||||
skip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
|
||||
if ((cc = config_binary_search(ce->name))) {
|
||||
if ((cc->conffunc) && (cc->conffunc(cfptr, ce) < 0))
|
||||
errors++;
|
||||
}
|
||||
else
|
||||
{
|
||||
int value;
|
||||
for (h = Hooks[HOOKTYPE_CONFIGRUN]; h; h = h->next)
|
||||
{
|
||||
value = (*(h->func.intfunc))(cfptr,ce,CONFIG_MAIN);
|
||||
if (value == 1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close_unbound_listeners();
|
||||
listen_cleanup();
|
||||
close_unbound_listeners();
|
||||
loop.do_bancheck = 1;
|
||||
config_switchover();
|
||||
update_throttling_timer_settings();
|
||||
|
||||
/* initialize conf_files with defaults if the block isn't set: */
|
||||
if (!conf_files)
|
||||
_conf_files(NULL, NULL);
|
||||
|
||||
if (errors > 0)
|
||||
{
|
||||
config_error("%i fatal errors encountered", errors);
|
||||
}
|
||||
return (errors > 0 ? -1 : 1);
|
||||
}
|
||||
|
||||
int config_test_blocks()
|
||||
{
|
||||
ConfigEntry *ce;
|
||||
|
@ -2882,6 +2792,96 @@ int config_test_blocks()
|
|||
return (errors > 0 ? -1 : 1);
|
||||
}
|
||||
|
||||
int config_run_blocks(void)
|
||||
{
|
||||
ConfigEntry *ce;
|
||||
ConfigFile *cfptr;
|
||||
ConfigCommand *cc;
|
||||
int errors = 0;
|
||||
int i;
|
||||
Hook *h;
|
||||
ConfigItem_allow *allow;
|
||||
|
||||
/* Stage 1: first the priority blocks, in the order as specified
|
||||
* in config_run_priority_blocks[]
|
||||
*/
|
||||
for (i=0; i < ARRAY_SIZEOF(config_run_priority_blocks); i++)
|
||||
{
|
||||
const char *config_block = config_run_priority_blocks[i];
|
||||
cc = config_binary_search(config_block);
|
||||
if (!cc)
|
||||
abort(); /* internal fuckup */
|
||||
if (!strcmp(config_block, "secret"))
|
||||
continue; /* yeah special case, we already processed the run part in test for these */
|
||||
for (cfptr = conf; cfptr; cfptr = cfptr->next)
|
||||
{
|
||||
if (config_verbose > 1)
|
||||
config_status("Running %s", cfptr->filename);
|
||||
for (ce = cfptr->items; ce; ce = ce->next)
|
||||
{
|
||||
if (!strcmp(ce->name, config_block))
|
||||
{
|
||||
if (cc->conffunc(cfptr, ce) < 0)
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Stage 2: now all the other config blocks */
|
||||
for (cfptr = conf; cfptr; cfptr = cfptr->next)
|
||||
{
|
||||
if (config_verbose > 1)
|
||||
config_status("Running %s", cfptr->filename);
|
||||
for (ce = cfptr->items; ce; ce = ce->next)
|
||||
{
|
||||
char skip = 0;
|
||||
for (i=0; i < ARRAY_SIZEOF(config_run_priority_blocks); i++)
|
||||
{
|
||||
if (!strcmp(ce->name, config_run_priority_blocks[i]))
|
||||
{
|
||||
skip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
|
||||
if ((cc = config_binary_search(ce->name))) {
|
||||
if ((cc->conffunc) && (cc->conffunc(cfptr, ce) < 0))
|
||||
errors++;
|
||||
}
|
||||
else
|
||||
{
|
||||
int value;
|
||||
for (h = Hooks[HOOKTYPE_CONFIGRUN]; h; h = h->next)
|
||||
{
|
||||
value = (*(h->func.intfunc))(cfptr,ce,CONFIG_MAIN);
|
||||
if (value == 1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close_unbound_listeners();
|
||||
listen_cleanup();
|
||||
close_unbound_listeners();
|
||||
loop.do_bancheck = 1;
|
||||
config_switchover();
|
||||
update_throttling_timer_settings();
|
||||
|
||||
/* initialize conf_files with defaults if the block isn't set: */
|
||||
if (!conf_files)
|
||||
_conf_files(NULL, NULL);
|
||||
|
||||
if (errors > 0)
|
||||
{
|
||||
config_error("%i fatal errors encountered", errors);
|
||||
}
|
||||
return (errors > 0 ? -1 : 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Service functions
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue