Index: cdr/cdr_adaptive_odbc.c =================================================================== --- cdr/cdr_adaptive_odbc.c (revision 90697) +++ cdr/cdr_adaptive_odbc.c (working copy) @@ -74,8 +74,21 @@ static AST_RWLIST_HEAD_STATIC(odbc_tables, tables); -static int load_config(void) +static int free_config(void) { + struct tables *table; + struct columns *entry; + while ((table = AST_RWLIST_REMOVE_HEAD(&odbc_tables, list))) { + while ((entry = AST_LIST_REMOVE_HEAD(&(table->columns), list))) { + ast_free(entry); + } + ast_free(table); + } + return 0; +} + +static int load_config(int reload) +{ struct ast_config *cfg; struct ast_variable *var; const char *tmp, *catg; @@ -89,12 +102,17 @@ SQLLEN sqlptr; int res = 0; SQLHSTMT stmt = NULL; - struct ast_flags config_flags = { 0 }; /* Part of our config comes from the database */ + struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; /* Part of our config comes from the database */ cfg = ast_config_load(CONFIG, config_flags); if (!cfg) { ast_log(LOG_WARNING, "Unable to load " CONFIG ". No adaptive ODBC CDRs.\n"); return -1; + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { + return 0; + } else if (reload) { + /* free the current configuration before loading the new one. */ + free_config(); } for (catg = ast_category_browse(cfg, NULL); catg; catg = ast_category_browse(cfg, catg)) { @@ -216,19 +234,6 @@ return res; } -static int free_config(void) -{ - struct tables *table; - struct columns *entry; - while ((table = AST_RWLIST_REMOVE_HEAD(&odbc_tables, list))) { - while ((entry = AST_LIST_REMOVE_HEAD(&(table->columns), list))) { - ast_free(entry); - } - ast_free(table); - } - return 0; -} - static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data) { int res, i; @@ -603,7 +608,7 @@ return 0; } - load_config(); + load_config(0); AST_RWLIST_UNLOCK(&odbc_tables); ast_cdr_register(name, ast_module_info->description, odbc_log); return 0; @@ -616,8 +621,7 @@ return -1; } - free_config(); - load_config(); + load_config(1); AST_RWLIST_UNLOCK(&odbc_tables); return 0; }