diff options
author | qwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-23 18:34:50 +0000 |
---|---|---|
committer | qwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-23 18:34:50 +0000 |
commit | 281108bceb7f52a232de33c0656ab68ade6d49e1 (patch) | |
tree | e926300f0e18ee62d262619a4b54efee5dd47e31 /res | |
parent | 9b08701667b4708d9ab65600d2a4bd8e60258a29 (diff) |
Merged revisions 114595 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r114595 | qwell | 2008-04-23 13:33:28 -0500 (Wed, 23 Apr 2008) | 16 lines
Merged revisions 114594 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r114594 | qwell | 2008-04-23 13:28:44 -0500 (Wed, 23 Apr 2008) | 8 lines
Fix reload/unload for res_musiconhold module.
(closes issue #11575)
Reported by: sunder
Patches:
M11575_14_rev3.diff uploaded by junky (license 177)
bug11575_trunk.diff.txt uploaded by jamesgolovich (license 176)
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@114596 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r-- | res/res_musiconhold.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index e7044eff9..64c9e71e9 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -1001,18 +1001,16 @@ static int moh_register(struct mohclass *moh, int reload) int x; #endif struct mohclass *mohclass = NULL; + int res = 0; AST_RWLIST_WRLOCK(&mohclasses); if ((mohclass = get_mohbyname(moh->name, 0)) && !moh_diff(mohclass, moh)) { - mohclass->delete = 0; - if (reload) { - ast_debug(1, "Music on Hold class '%s' left alone from initial load.\n", moh->name); - } else { + if (!mohclass->delete) { ast_log(LOG_WARNING, "Music on Hold class '%s' already exists\n", moh->name); + ast_free(moh); + AST_RWLIST_UNLOCK(&mohclasses); + return -1; } - ast_free(moh); - AST_RWLIST_UNLOCK(&mohclasses); - return -1; } AST_RWLIST_UNLOCK(&mohclasses); @@ -1020,7 +1018,12 @@ static int moh_register(struct mohclass *moh, int reload) moh->start -= respawn_time; if (!strcasecmp(moh->mode, "files")) { - if (!moh_scan_files(moh)) { + res = moh_scan_files(moh); + if (res <= 0) { + if (res == 0) { + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_3 "Files not found in %s for moh class:%s\n", moh->dir, moh->name); + } ast_moh_free_class(&moh); return -1; } @@ -1577,14 +1580,6 @@ static int init_classes(int reload) AST_RWLIST_REMOVE_CURRENT(list); if (!moh->inuse) ast_moh_destroy_one(moh); - } else if (moh->total_files) { - if (moh_scan_files(moh) <= 0) { - ast_log(LOG_WARNING, "No files found for class '%s'\n", moh->name); - moh->delete = 1; - AST_LIST_REMOVE_CURRENT(list); - if (!moh->inuse) - ast_moh_destroy_one(moh); - } } } AST_RWLIST_TRAVERSE_SAFE_END @@ -1628,7 +1623,31 @@ static int reload(void) static int unload_module(void) { - return -1; + int res = 0; + struct mohclass *class = NULL; + + AST_RWLIST_WRLOCK(&mohclasses); + AST_LIST_TRAVERSE(&mohclasses, class, list) { + if (class->inuse > 0) { + res = -1; + break; + } + } + AST_RWLIST_UNLOCK(&mohclasses); + if (res < 0) { + ast_log(LOG_WARNING, "Unable to unload res_musiconhold due to active MOH channels\n"); + return res; + } + + ast_uninstall_music_functions(); + ast_moh_destroy(); + res = ast_unregister_application(play_moh); + res |= ast_unregister_application(wait_moh); + res |= ast_unregister_application(set_moh); + res |= ast_unregister_application(start_moh); + res |= ast_unregister_application(stop_moh); + ast_cli_unregister_multiple(cli_moh, sizeof(cli_moh) / sizeof(struct ast_cli_entry)); + return res; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Music On Hold Resource", |