]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Use the MACRO_CONTEXT and MACRO_EXTEN channel variables instead of the channel's...
authorMark Michelson <mmichelson@digium.com>
Tue, 29 Apr 2008 19:40:06 +0000 (19:40 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 29 Apr 2008 19:40:06 +0000 (19:40 +0000)
and macroexten fields. This is needed because if macros are daisy-chained, the incorrect
context and extension are placed on the new channel. I also added locking to the channel prior
to accessing these variables as noted in trunk's janitor project file.

(closes issue #12549)
Reported by: darren1713
Patches:
      app_queue.c.macroextenpatch uploaded by darren1713 (license 116)
       (with modifications from me)
Tested by: putnopvut

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

apps/app_queue.c

index f3b331a8773ac57a6596a4388dc76c44680f071e..313163576fb49e8056488498fdf808f3eca42d26 100644 (file)
@@ -1784,6 +1784,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
        int status;
        char tech[256];
        char *location;
+       const char *macrocontext, *macroexten;
 
        /* on entry here, we know that tmp->chan == NULL */
        if (qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime)) {
@@ -1865,14 +1866,18 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
        tmp->chan->adsicpe = qe->chan->adsicpe;
 
        /* Inherit context and extension */
-       if (!ast_strlen_zero(qe->chan->macrocontext))
-               ast_copy_string(tmp->chan->dialcontext, qe->chan->macrocontext, sizeof(tmp->chan->dialcontext));
+       ast_channel_lock(qe->chan);
+       macrocontext = pbx_builtin_getvar_helper(qe->chan, "MACRO_CONTEXT");
+       if (!ast_strlen_zero(macrocontext))
+               ast_copy_string(tmp->chan->dialcontext, macrocontext, sizeof(tmp->chan->dialcontext));
        else
                ast_copy_string(tmp->chan->dialcontext, qe->chan->context, sizeof(tmp->chan->dialcontext));
-       if (!ast_strlen_zero(qe->chan->macroexten))
-               ast_copy_string(tmp->chan->exten, qe->chan->macroexten, sizeof(tmp->chan->exten));
+       macroexten = pbx_builtin_getvar_helper(qe->chan, "MACRO_EXTEN");
+       if (!ast_strlen_zero(macroexten))
+               ast_copy_string(tmp->chan->exten, macroexten, sizeof(tmp->chan->exten));
        else
                ast_copy_string(tmp->chan->exten, qe->chan->exten, sizeof(tmp->chan->exten));
+       ast_channel_unlock(qe->chan);
 
        /* Place the call, but don't wait on the answer */
        if ((res = ast_call(tmp->chan, location, 0))) {