]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Makes parking lots clear and rebuild properly when features reload is invoked from CLI
authorJonathan Rose <jrose@digium.com>
Thu, 7 Apr 2011 13:23:01 +0000 (13:23 +0000)
committerJonathan Rose <jrose@digium.com>
Thu, 7 Apr 2011 13:23:01 +0000 (13:23 +0000)
Before, default parkinglot in context parkedcalls with ext 700 would always be present and when reload was invoked, the previous parkinglots would not be cleared.

(closes issue #18801)
Reported by: mickecarlsson

Review: https://reviewboard.asterisk.org/r/1161/

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

main/features.c

index dc6fe8eaf5e06fef4c3e2d93ede14266f8cb1b55..1b1d55b8824cfc0a3d3b249b84fe788d764098f5 100644 (file)
@@ -4189,6 +4189,17 @@ static int load_config(void)
                "applicationmap"
        };
 
+       /* Clear the existing parkinglots in the parkinglots container. */
+       {
+               struct ast_parkinglot *p;
+               struct ao2_iterator iter = ao2_iterator_init(parkinglots, 0);
+               while ((p = ao2_iterator_next(&iter))) {
+                       ao2_unlink(parkinglots, p);
+                       ao2_ref(p,-1);
+               }
+               ao2_iterator_destroy(&iter);
+       }
+
        if (default_parkinglot) {
                strcpy(old_parking_con, default_parkinglot->parking_con);
                strcpy(old_parking_ext, parking_ext);
@@ -4242,7 +4253,19 @@ static int load_config(void)
                ast_log(LOG_WARNING,"Could not load features.conf\n");
                return 0;
        }
-       for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
+
+       if ((var = ast_variable_browse(cfg, "general"))) {
+               /* Find a general context in features.conf, we need to clear our existing default context */
+               /* Can't outright destroy the parking lot because it's needed in a little while. */
+               if ((con = ast_context_find(default_parkinglot->parking_con))) {
+                       ast_context_destroy(con, registrar);
+               }
+               if ((con = ast_context_find(default_parkinglot->parking_con_dial))) {
+                       ast_context_destroy(con, registrar);
+               }
+       } 
+
+       for (; var; var = var->next) {
                if (!strcasecmp(var->name, "parkext")) {
                        ast_copy_string(parking_ext, var->value, sizeof(parking_ext));
                } else if (!strcasecmp(var->name, "context")) {