]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't forget to rescan MOH files for cached realtime classes
authorTerry Wilson <twilson@digium.com>
Sat, 12 Nov 2011 00:24:43 +0000 (00:24 +0000)
committerTerry Wilson <twilson@digium.com>
Sat, 12 Nov 2011 00:24:43 +0000 (00:24 +0000)
Realtime MOH class caching was implemented because without it, you would build
a completely new MOH class and would start the music over at the beginning each
time hold was pressed in a conversation. Unfortunately, this broke re-scanning
for file changes for realtime MOH classes. This patch corrects that issue.

(closes issue ASTERISK-18039)
Review: https://reviewboard.asterisk.org/r/1579/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@344899 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_musiconhold.c

index 386376e6851c136118d16e689cf590b0bfc2706f..4201828f9e3da1b012b6d2233327ae90cd31c294 100644 (file)
@@ -1495,6 +1495,7 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con
                        }
                } else {
                        ast_variables_destroy(var);
+                       var = NULL;
                }
        }
 
@@ -1502,6 +1503,14 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con
                return -1;
        }
 
+       /* If we are using a cached realtime class with files, re-scan the files */
+       if (!var && ast_test_flag(global_flags, MOH_CACHERTCLASSES) && mohclass->realtime && !strcasecmp(mohclass->mode, "files")) {
+               if (!moh_scan_files(mohclass)) {
+                       mohclass = mohclass_unref(mohclass, "unreffing potential mohclass (moh_scan_files failed)");
+                       return -1;
+               }
+       }
+
        ast_manager_event(chan, EVENT_FLAG_CALL, "MusicOnHold",
                "State: Start\r\n"
                "Channel: %s\r\n"