]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
followme: initialize all config items on reload 81/3581/2
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>
Thu, 11 Aug 2016 17:10:44 +0000 (20:10 +0300)
committerJoshua Colp <jcolp@digium.com>
Wed, 7 Sep 2016 11:40:20 +0000 (11:40 +0000)
Some configuration directives were not initialized on reload, and hence
were not reset to default if they were removed from followme.conf.

ASTERISK-26288 #close

Change-Id: Ief829e16374ad1e0ecfd63e6ee4923b5a1d1c150

apps/app_followme.c

index dfb0f0e62a42ac490896cd43726d9f10147c4840..e05d95bc74fa0c5f8e70b4f1125ce86db49bbe52 100644 (file)
@@ -303,8 +303,16 @@ static struct call_followme *alloc_profile(const char *fmname)
 
        ast_mutex_init(&f->lock);
        ast_copy_string(f->name, fmname, sizeof(f->name));
-       f->moh[0] = '\0';
+       AST_LIST_HEAD_INIT_NOLOCK(&f->numbers);
+       AST_LIST_HEAD_INIT_NOLOCK(&f->blnumbers);
+       AST_LIST_HEAD_INIT_NOLOCK(&f->wlnumbers);
+       return f;
+}
+
+static void init_profile(struct call_followme *f, int activate)
+{
        f->context[0] = '\0';
+       ast_copy_string(f->moh, defaultmoh, sizeof(f->moh));
        ast_copy_string(f->takecall, takecall, sizeof(f->takecall));
        ast_copy_string(f->nextindp, nextindp, sizeof(f->nextindp));
        ast_copy_string(f->callfromprompt, callfromprompt, sizeof(f->callfromprompt));
@@ -313,16 +321,9 @@ static struct call_followme *alloc_profile(const char *fmname)
        ast_copy_string(f->plsholdprompt, plsholdprompt, sizeof(f->plsholdprompt));
        ast_copy_string(f->statusprompt, statusprompt, sizeof(f->statusprompt));
        ast_copy_string(f->sorryprompt, sorryprompt, sizeof(f->sorryprompt));
-       AST_LIST_HEAD_INIT_NOLOCK(&f->numbers);
-       AST_LIST_HEAD_INIT_NOLOCK(&f->blnumbers);
-       AST_LIST_HEAD_INIT_NOLOCK(&f->wlnumbers);
-       return f;
-}
-
-static void init_profile(struct call_followme *f)
-{
-       f->active = 1;
-       ast_copy_string(f->moh, defaultmoh, sizeof(f->moh));
+       if (activate) {
+               f->active = 1;
+       }
 }
 
    
@@ -495,7 +496,7 @@ static int reload_followme(int reload)
                if (!new)
                        ast_mutex_lock(&f->lock);
                /* Re-initialize the profile */
-               init_profile(f);
+               init_profile(f, 1);
                free_numbers(f);
                var = ast_variable_browse(cfg, cat);
                while (var) {
@@ -1220,6 +1221,7 @@ static struct call_followme *find_realtime(const char *name)
                ast_free(str);
                return NULL;
        }
+       init_profile(new_follower, 0);
 
        for (v = var; v; v = v->next) {
                if (!strcasecmp(v->name, "active")) {