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

Matthew Jordan mjordan at digium.com
Thu Feb 23 08:26:18 CST 2012


----- Original Message ----- 

> From: "Johan Wilfer" <lists at jttech.se>
> To: asterisk-dev at lists.digium.com
> Sent: Thursday, February 23, 2012 5:54:30 AM
> Subject: Re: [asterisk-dev] (ASTERISK-19336) h exten is not run in
> the context that calls a AEL macro

> Hi!

> 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."

> context conference {
> incoming => {
> &testmacro();
> }

> h => {
> Noop(Called from the context that invokes the macro - THIS DOESN'T
> WORK);
> }
> }

> macro testmacro() {
> Noop(Running testmacro!);
> Wait(20);
> }

> Connected to Asterisk 1.8.9.2 currently running on dev01 (pid = 3762)
> -- Executing [incoming at conference:1] Gosub("SIP/trunk-00000000",
> "testmacro,~~s~~,1") in new stack
> -- Executing [~~s~~@testmacro:1] NoOp("SIP/trunk-00000000", "ning
> testmacro!") in new stack
> -- Executing [~~s~~@testmacro:2] Wait("SIP/trunk-00000000", "20") in
> new stack
> == Spawn extension (testmacro, ~~s~~, 2) exited non-zero on
> 'SIP/trunk-00000000'

Your log statements illustrate exactly what the description of the h
extension on the wiki says it does.  Your call is not hung up in the
conference context, but in the macro context testmacro.  Hence, it looks
for a hangup handler in that context; when it doesn't find one, it exits.

> I like your hangup-handlers-patch, it seems like a nice solution.
> Right now I can't use macros in ael where it's important to run the
> code in the hangup exten, so I use gosub insted and use h => { goto
> main_context,h,1 }.
> However, this is quite hackish and the ael parser try to advice me
> otherwise on every reload ("gosub affects call flow...").

> /Johan

Matthew Jordan
Digium, Inc. | Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org



More information about the asterisk-dev mailing list