diff --git a/res/res_statsd.c b/res/res_statsd.c index 67166e8208144a09b0a50fe3ca0f84a8590de5fd..f94876ef88a296a867fde22a4a04aac4ff966131 100644 --- a/res/res_statsd.c +++ b/res/res_statsd.c @@ -318,6 +318,14 @@ static void statsd_shutdown(void) } } +static int unload_module(void) +{ + statsd_shutdown(); + aco_info_destroy(&cfg_info); + ao2_global_obj_release(confs); + return 0; +} + static int load_module(void) { if (aco_info_init(&cfg_info)) { @@ -350,8 +358,8 @@ static int load_module(void) return AST_MODULE_LOAD_SUCCESS; } - if (statsd_init() != 0) { - aco_info_destroy(&cfg_info); + if (statsd_init()) { + unload_module(); return AST_MODULE_LOAD_DECLINE; } @@ -361,26 +369,26 @@ static int load_module(void) return AST_MODULE_LOAD_SUCCESS; } -static int unload_module(void) -{ - statsd_shutdown(); - aco_info_destroy(&cfg_info); - ao2_global_obj_release(confs); - return 0; -} - static int reload_module(void) { - if (aco_process_config(&cfg_info, 1)) { + switch (aco_process_config(&cfg_info, 1)) { + case ACO_PROCESS_OK: + break; + case ACO_PROCESS_UNCHANGED: + return AST_MODULE_LOAD_SUCCESS; + case ACO_PROCESS_ERROR: + default: return AST_MODULE_LOAD_DECLINE; } if (is_enabled()) { - return statsd_init(); + if (statsd_init()) { + return AST_MODULE_LOAD_DECLINE; + } } else { statsd_shutdown(); - return AST_MODULE_LOAD_SUCCESS; } + return AST_MODULE_LOAD_SUCCESS; } /* The priority of this module is set to be as low as possible, since it could