[asterisk-dev] (ASTERISK-19336) h exten is not run in the context that calls a AEL macro

Johan Wilfer lists at jttech.se
Mon Feb 27 10:33:16 CST 2012


2012-02-23 15:26, Matthew Jordan skrev:
>> But if I change the code to scenario 1, no h-exten is run, is this
>> the intended behaviour?
> Yes.  From https://wiki.asterisk.org/wiki/display/AST/Handling+Special+Extensions:
>
> "When a call is hung up, Asterisk executes the h extension in the current context."

This is a change in functionality to the less from 1.4 (which I'm
converting my dialplan from)

In 1.4 an AEL macro was implemented with the Macro-application and not
gosub, and my example works.
The h-exten is run in the calling context, despite that hangup occurs in
the Macro.

    -- Executing [incoming at conference:2] Macro("SIP/trunk-00000000",
"testmacro") in new stack
    -- Executing [s at macro-testmacro:1] NoOp("SIP/trunk-00000000",
"Running testmacro!") in new stack
    -- Executing [s at macro-testmacro:2] Wait("SIP/trunk-00000000", "20")
in new stack
  == Spawn extension (macro-testmacro, s, 2) exited non-zero on
'SIP/trunk-00000000' in macro 'testmacro'
  == Spawn extension (conference, incoming, 2) exited non-zero on
'SIP/trunk-00000000'
    -- Executing [h at conference:1] NoOp("SIP/trunk-00000000", "Called
from the context that invokes the macro - THIS DOESN'T WORK") in new stack

This change in >1.6 makes it hard to actually use macros for anything
complex as I have to duplicate hangup-code in every macro, and even
duplicate the same macro for different contexts calling the macro!

To add to that, in 1.4 there was channel variables to know the context
invoking the macro. This is also less functionality in newer versions.
For the call above these variables are set in 1.4:

MACRO_DEPTH=1
MACRO_PRIORITY=2
MACRO_CONTEXT=conference
MACRO_EXTEN=incoming

None of these variables are present anymore.
If these variables were present in 1.8 and forward you could make a work
around like this:

catch h {
  if (!${DIALPLAN_EXISTS(${MACRO_CONTEXT},h,1)}) {
    goto ${MACRO_CONTEXT}, h, 1;
  }
}

I would argue that this should be inserted by default by the ael-parser
to make asterisk behave like in 1.4.
This way macro's would be much more flexible and useful even in complex
dialplans.

-- 
Johan Wilfer                 email: johan at jttech.se
JT Tech | Developer          webb: http://jttech.se




More information about the asterisk-dev mailing list