fixes subscriptions being lost after 'module reload'
authorDavid Vossel <dvossel@digium.com>
Tue, 5 Jan 2010 19:29:47 +0000 (19:29 +0000)
committerDavid Vossel <dvossel@digium.com>
Tue, 5 Jan 2010 19:29:47 +0000 (19:29 +0000)
During a module reload if multiple extension configs are present,
such as both extensions.conf and extensions.ael, watchers for one
config's hints will be lost during the merging of the other config.

This happens because hint watchers are only preserved for the
current config being merged.  The old context list is destroyed
after the merging takes place, meaning any watchers that were not
perserved will be removed.

Now all hints are preserved during merging regardless of what config
file is being merged.  These hints are only restored if they
are present within the new context list.

(closes issue #16093)
Reported by: jlaroff

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

main/pbx.c

index 45e46df..ed14a65 100644 (file)
@@ -6968,12 +6968,13 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_
        AST_RWLIST_WRLOCK(&hints);
        writelocktime = ast_tvnow();
 
        AST_RWLIST_WRLOCK(&hints);
        writelocktime = ast_tvnow();
 
-       /* preserve all watchers for hints associated with this registrar */
+       /* preserve all watchers for hints */
        AST_RWLIST_TRAVERSE(&hints, hint, list) {
        AST_RWLIST_TRAVERSE(&hints, hint, list) {
-               if (!AST_LIST_EMPTY(&hint->callbacks) && !strcmp(registrar, hint->exten->parent->registrar)) {
+               if (!AST_LIST_EMPTY(&hint->callbacks)) {
                        length = strlen(hint->exten->exten) + strlen(hint->exten->parent->name) + 2 + sizeof(*this);
                        if (!(this = ast_calloc(1, length)))
                                continue;
                        length = strlen(hint->exten->exten) + strlen(hint->exten->parent->name) + 2 + sizeof(*this);
                        if (!(this = ast_calloc(1, length)))
                                continue;
+                       /* this removes all the callbacks from the hint into this. */
                        AST_LIST_APPEND_LIST(&this->callbacks, &hint->callbacks, entry);
                        this->laststate = hint->laststate;
                        this->context = this->data;
                        AST_LIST_APPEND_LIST(&this->callbacks, &hint->callbacks, entry);
                        this->laststate = hint->laststate;
                        this->context = this->data;
@@ -7004,7 +7005,7 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_
                 */
                if (exten && exten->exten[0] == '_') {
                        ast_add_extension_nolock(exten->parent->name, 0, this->exten, PRIORITY_HINT, NULL,
                 */
                if (exten && exten->exten[0] == '_') {
                        ast_add_extension_nolock(exten->parent->name, 0, this->exten, PRIORITY_HINT, NULL,
-                               0, exten->app, ast_strdup(exten->data), ast_free_ptr, registrar);
+                               0, exten->app, ast_strdup(exten->data), ast_free_ptr, exten->registrar);
                        /* rwlocks are not recursive locks */
                        exten = ast_hint_extension_nolock(NULL, this->context, this->exten);
                }
                        /* rwlocks are not recursive locks */
                        exten = ast_hint_extension_nolock(NULL, this->context, this->exten);
                }