Index: cdr/cdr_addon_mysql.c =================================================================== --- cdr/cdr_addon_mysql.c (revision 707) +++ cdr/cdr_addon_mysql.c (working copy) @@ -340,7 +340,7 @@ return 0; } -static int my_unload_module(void) +static int my_unload_module(int reload) { struct unload_string *us; struct column *entry; @@ -360,11 +360,15 @@ } AST_LIST_UNLOCK(&unload_strings); - AST_RWLIST_WRLOCK(&columns); + if (!reload) { + AST_RWLIST_WRLOCK(&columns); + } while ((entry = AST_RWLIST_REMOVE_HEAD(&columns, list))) { ast_free(entry); } - AST_RWLIST_UNLOCK(&columns); + if (!reload) { + AST_RWLIST_UNLOCK(&columns); + } dbport = 0; ast_cdr_unregister(name); @@ -433,12 +437,17 @@ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) return AST_MODULE_LOAD_SUCCESS; - if (reload) - my_unload_module(); + if (reload) { + AST_RWLIST_WRLOCK(&columns); + my_unload_module(1); + } var = ast_variable_browse(cfg, "global"); if (!var) { /* nothing configured */ + if (reload) { + AST_RWLIST_UNLOCK(&columns); + } return AST_MODULE_LOAD_SUCCESS; } @@ -467,11 +476,17 @@ } if (res < 0) { + if (reload) { + AST_RWLIST_UNLOCK(&columns); + } return AST_MODULE_LOAD_FAILURE; } /* Check for any aliases */ - AST_RWLIST_WRLOCK(&columns); + if (!reload) { + /* Lock, if not already */ + AST_RWLIST_WRLOCK(&columns); + } while ((entry = AST_LIST_REMOVE_HEAD(&columns, list))) { ast_free(entry); } @@ -625,7 +640,7 @@ static int unload_module(void) { - return my_unload_module(); + return my_unload_module(0); } static int reload(void)