Index: cdr/cdr_addon_mysql.c =================================================================== --- cdr/cdr_addon_mysql.c (revision 712) +++ cdr/cdr_addon_mysql.c (working copy) @@ -332,7 +332,7 @@ return 0; } -static int my_unload_module(void) +static int my_unload_module(int reload) { struct unload_string *us; struct column *entry; @@ -352,11 +352,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); @@ -425,12 +429,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; } @@ -456,11 +465,18 @@ calldate_compat = 0; } - if (res < 0) + 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); } @@ -583,7 +599,7 @@ static int unload_module(void) { - return my_unload_module(); + return my_unload_module(0); } static int reload(void)