From bfd14294c65e062f837f6fd3f24d837ca36dca36 Mon Sep 17 00:00:00 2001 From: nappsoft Date: Thu, 2 Apr 2026 16:07:51 +0200 Subject: [PATCH] res_cdrel_custom: do not free config when no new config was loaded When the res_cdrel_custom modules is reloaded and the config has not been changed asterisk should not free the old config. Otherwise the connection to the database will be closed and no new connection will be opened. Resolves: #1852 --- res/cdrel_custom/config.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/res/cdrel_custom/config.c b/res/cdrel_custom/config.c index 49543df3d2..1017e1de5e 100644 --- a/res/cdrel_custom/config.c +++ b/res/cdrel_custom/config.c @@ -1053,7 +1053,7 @@ static int load_database_config_file(enum cdrel_record_type record_type, struct return -1; } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ast_debug(1, "%s: Config file unchanged, not reloading\n", config_filename); - return 0; + return 1; } while ((category = ast_category_browse_filtered(cfg, NULL, category, NULL))) { @@ -1322,7 +1322,7 @@ static int load_text_file_config_file(enum cdrel_record_type record_type, return -1; } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ast_debug(1, "%s: Config file unchanged, not reloading\n", config_filename); - return 0; + return 1; } while ((category = ast_category_browse_filtered(cfg, NULL, category, NULL))) { @@ -1409,23 +1409,22 @@ int cdrel_reload_module(enum cdrel_backend_type output_type, enum cdrel_record_t } res = load_config_file(output_type, record_type, new_configs, filename, 1); - if (res != 0) { + if (res < 0) { AST_VECTOR_RESET(new_configs, config_free); AST_VECTOR_PTR_FREE(new_configs); return AST_MODULE_LOAD_DECLINE; } - /* Now swap the new ones in. */ - *configs = new_configs; + if (res == 0) { + /* Now swap the new ones in. */ + *configs = new_configs; - /* Free the old ones. */ - AST_VECTOR_RESET(old_configs, config_free); - AST_VECTOR_PTR_FREE(old_configs); + /* Free the old ones. */ + AST_VECTOR_RESET(old_configs, config_free); + AST_VECTOR_PTR_FREE(old_configs); + } return AST_MODULE_LOAD_SUCCESS; - - - return -1; } struct cdrel_configs *cdrel_load_module(enum cdrel_backend_type backend_type,