diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-11-16 17:48:18 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-11-16 17:48:18 +0000 |
commit | 5f6ab90eb2239b9b76083fbeebbf6bf0c644ab07 (patch) | |
tree | c1adcfd876fe79894f93a50b1da7cb0a24f5862a | |
parent | 224cc3b5171d8ec49536e7a0a737cf06b784dbbf (diff) |
issue #5766
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7116 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | ChangeLog | 2 | ||||
-rwxr-xr-x | res/res_musiconhold.c | 28 |
2 files changed, 19 insertions, 11 deletions
@@ -1,5 +1,7 @@ 2005-11-16 Kevin P. Fleming <kpfleming@limerick.digium.com> + * res/res_musiconhold.c: don't spit out incorrect log messages (and leak memory) during reload (issue #5766) + * channels/chan_sip.c (process_sdp): don't pass video codec number into ast_getformatname(), it is not valid input for that function (issue #5764) * pbx/pbx_ael.c (match_assignment): properly parse equal signs surrounded by whitespace (issue #5761) diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 2939659dc..10bd5b2ad 100755 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -785,14 +785,18 @@ static int moh_scan_files(struct mohclass *class) { return class->total_files; } -static int moh_register(struct mohclass *moh) +static int moh_register(struct mohclass *moh, int reload) { #ifdef ZAPATA_MOH int x; #endif ast_mutex_lock(&moh_lock); if (get_mohbyname(moh->name)) { - ast_log(LOG_WARNING, "Music on Hold class '%s' already exists\n", moh->name); + if (reload) { + ast_log(LOG_DEBUG, "Music on Hold class '%s' left alone from initial load.\n", moh->name); + } else { + ast_log(LOG_WARNING, "Music on Hold class '%s' already exists\n", moh->name); + } free(moh); ast_mutex_unlock(&moh_lock); return -1; @@ -914,7 +918,7 @@ static struct mohclass *moh_class_malloc(void) return class; } -static int load_moh_classes(void) +static int load_moh_classes(int reload) { struct ast_config *cfg; struct ast_variable *var; @@ -979,7 +983,9 @@ static int load_moh_classes(void) continue; } - moh_register(class); + /* Don't leak a class when it's already registered */ + moh_register(class, reload); + numclasses++; } } @@ -1011,7 +1017,7 @@ static int load_moh_classes(void) if (args) ast_copy_string(class->args, args, sizeof(class->args)); - moh_register(class); + moh_register(class, reload); numclasses++; } } @@ -1039,7 +1045,7 @@ static int load_moh_classes(void) if (args) ast_copy_string(class->args, args, sizeof(class->args)); - moh_register(class); + moh_register(class, reload); numclasses++; } var = var->next; @@ -1103,7 +1109,7 @@ static int moh_cli(int fd, int argc, char *argv[]) moh_on_off(0); ast_moh_destroy(); - x = load_moh_classes(); + x = load_moh_classes(1); moh_on_off(1); ast_cli(fd, "\n%d class%s reloaded.\n", x, x == 1 ? "" : "es"); return 0; @@ -1152,11 +1158,11 @@ static struct ast_cli_entry cli_moh_classes_show = { { "moh", "classes", "show" static struct ast_cli_entry cli_moh_files_show = { { "moh", "files", "show"}, cli_files_show, "List MOH file-based classes", "Lists all loaded file-based MOH classes and their files", NULL}; -static int init_classes(void) +static int init_classes(int reload) { struct mohclass *moh; - if (!load_moh_classes()) /* Load classes from config */ + if (!load_moh_classes(reload)) /* Load classes from config */ return 0; /* Return if nothing is found */ moh = mohclasses; while (moh) { @@ -1185,7 +1191,7 @@ int load_module(void) if (!res) res = ast_register_application(app4, moh4_exec, synopsis4, descrip4); - if (!init_classes()) { /* No music classes configured, so skip it */ + if (!init_classes(0)) { /* No music classes configured, so skip it */ ast_log(LOG_WARNING, "No music on hold classes configured, disabling music on hold."); } else { ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop, local_ast_moh_cleanup); @@ -1196,7 +1202,7 @@ int load_module(void) int reload(void) { - if (init_classes()) + if (init_classes(1)) ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop, local_ast_moh_cleanup); return 0; |