mirror of
https://github.com/pissnet/pissircd.git
synced 2025-07-28 22:12:25 +01:00
Set loop.config_state to one of CONFIG_STATE_* so modules (and core)
can track at what step we are during configuration file and module processing.
This commit is contained in:
parent
0a4c6e877d
commit
b38b0f5086
4 changed files with 34 additions and 2 deletions
|
@ -791,6 +791,20 @@ struct MOTDLine {
|
|||
struct MOTDLine *next;
|
||||
};
|
||||
|
||||
/** Current status of configuration in memory (what stage are we in..) */
|
||||
typedef enum ConfigStatus {
|
||||
CONFIG_STATUS_NONE = 0, /**< Config files have not been parsed yet */
|
||||
CONFIG_STATUS_TEST = 1, /**< Currently running MOD_TEST() */
|
||||
CONFIG_STATUS_POSTTEST = 2, /**< Currently running post_config_test hooks */
|
||||
CONFIG_STATUS_PRE_INIT = 3, /**< In-between */
|
||||
CONFIG_STATUS_INIT = 4, /**< Currently running MOD_INIT() */
|
||||
CONFIG_STATUS_RUN_CONFIG = 5, /**< Currently running CONFIG_RUN hooks */
|
||||
CONFIG_STATUS_LOAD = 6, /**< Currently running MOD_LOAD() */
|
||||
CONFIG_STATUS_POSTLOAD = 7, /**< Doing post-load stuff like activating listeners */
|
||||
CONFIG_STATUS_COMPLETE = 8, /**< Load or rehash complete */
|
||||
CONFIG_STATUS_ROLLBACK = 99, /**< Configuration failed, rolling back changes */
|
||||
} ConfigStatus;
|
||||
|
||||
struct LoopStruct {
|
||||
unsigned do_garbage_collect : 1;
|
||||
unsigned config_test : 1;
|
||||
|
@ -804,6 +818,7 @@ struct LoopStruct {
|
|||
unsigned rehash_download_busy : 1; /* don't return "all downloads complete", needed for race condition */
|
||||
unsigned tainted : 1;
|
||||
int rehashing;
|
||||
ConfigStatus config_status;
|
||||
Client *rehash_save_client;
|
||||
void (*boot_function)();
|
||||
};
|
||||
|
|
10
src/conf.c
10
src/conf.c
|
@ -1981,6 +1981,7 @@ void config_load_failed(void)
|
|||
{
|
||||
if (conf)
|
||||
unreal_log(ULOG_ERROR, "config", "CONFIG_NOT_LOADED", NULL, "IRCd configuration failed to load");
|
||||
loop.config_status = CONFIG_STATUS_ROLLBACK;
|
||||
Unload_all_testing_modules();
|
||||
free_all_config_resources();
|
||||
config_free(conf);
|
||||
|
@ -2053,6 +2054,7 @@ int config_test(void)
|
|||
}
|
||||
|
||||
config_status("Testing IRCd configuration..");
|
||||
loop.config_status = CONFIG_STATUS_TEST;
|
||||
|
||||
memset(&tempiConf, 0, sizeof(iConf));
|
||||
memset(&settings, 0, sizeof(settings));
|
||||
|
@ -2071,12 +2073,14 @@ int config_test(void)
|
|||
|
||||
preprocessor_resolve_conditionals_all(PREPROCESSOR_PHASE_MODULE);
|
||||
|
||||
loop.config_status = CONFIG_STATUS_POSTTEST;
|
||||
if (!config_test_all())
|
||||
{
|
||||
config_error("IRCd configuration failed to pass testing");
|
||||
config_load_failed();
|
||||
return -1;
|
||||
}
|
||||
loop.config_status = CONFIG_STATUS_PRE_INIT;
|
||||
callbacks_switchover();
|
||||
efunctions_switchover();
|
||||
set_targmax_defaults();
|
||||
|
@ -2101,8 +2105,10 @@ int config_test(void)
|
|||
}
|
||||
config_pre_run_log();
|
||||
|
||||
loop.config_status = CONFIG_STATUS_INIT;
|
||||
Init_all_testing_modules();
|
||||
|
||||
loop.config_status = CONFIG_STATUS_RUN_CONFIG;
|
||||
if (config_run_blocks() < 0)
|
||||
{
|
||||
config_error("Bad case of config errors. Server will now die. This really shouldn't happen");
|
||||
|
@ -2126,9 +2132,11 @@ int config_test(void)
|
|||
conf = NULL;
|
||||
if (loop.rehashing)
|
||||
{
|
||||
/* loop.config_status = CONFIG_STATUS_LOAD is done by module_loadall() */
|
||||
module_loadall();
|
||||
RunHook(HOOKTYPE_REHASH_COMPLETE);
|
||||
}
|
||||
loop.config_status = CONFIG_STATUS_POSTLOAD;
|
||||
postconf();
|
||||
unreal_log(ULOG_INFO, "config", "CONFIG_LOADED", NULL, "Configuration loaded");
|
||||
clicap_post_rehash();
|
||||
|
@ -9608,6 +9616,7 @@ void start_listeners(void)
|
|||
/* Actually use configuration */
|
||||
void config_run(void)
|
||||
{
|
||||
loop.config_status = CONFIG_STATUS_POSTLOAD;
|
||||
extcmodes_check_for_changes();
|
||||
start_listeners();
|
||||
add_proc_io_server();
|
||||
|
@ -10820,6 +10829,7 @@ int rehash_internal(Client *client)
|
|||
loop.rehashing = 0;
|
||||
remote_rehash_client = NULL;
|
||||
procio_post_rehash(failure);
|
||||
loop.config_status = CONFIG_STATUS_COMPLETE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -856,6 +856,7 @@ int InitUnrealIRCd(int argc, char *argv[])
|
|||
PS_STRINGS->ps_argvstr = me.name;
|
||||
#endif
|
||||
module_loadall();
|
||||
loop.config_status = CONFIG_STATUS_COMPLETE;
|
||||
|
||||
#ifndef _WIN32
|
||||
SocketLoop(NULL);
|
||||
|
|
|
@ -734,6 +734,8 @@ void module_loadall(void)
|
|||
iFP fp;
|
||||
Module *mi, *next;
|
||||
|
||||
loop.config_status = CONFIG_STATUS_LOAD;
|
||||
|
||||
/* Run through all modules and check for module load */
|
||||
for (mi = Modules; mi; mi = next)
|
||||
{
|
||||
|
@ -1338,11 +1340,15 @@ int is_module_loaded(const char *name)
|
|||
if (mi->flags & MODFLAG_DELAYED)
|
||||
continue; /* unloading (delayed) */
|
||||
|
||||
/* During testing/rehashing, ignore modules that are loaded,
|
||||
/* During config_posttest ignore modules that are loaded,
|
||||
* since we only care about the 'future' state.
|
||||
*/
|
||||
if ((loop.rehashing == 2) && (mi->flags == MODFLAG_LOADED))
|
||||
if ((loop.config_status < CONFIG_STATUS_LOAD) &&
|
||||
(loop.config_status >= CONFIG_STATUS_POSTTEST) &&
|
||||
(mi->flags == MODFLAG_LOADED))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcasecmp(mi->relpath, name))
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue