[asterisk-users] endwhile jumping out of macro
Matthew Jordan
mjordan at digium.com
Mon Nov 30 09:40:50 CST 2015
On Sat, Nov 28, 2015 at 7:14 AM, Ethy H. Brito <ethy.brito at inexo.com.br>
wrote:
>
> Hi
>
> I have a 3 level nested while-endwhile loop in a macro that when the
> execution reaches endwhile, it is jumping out to the While at the caller
> macro.
>
> It shouldn't since the are instructions after the endwhile.
>
> -- Executing [s at macro-call-from-outside:72]
> EndWhile("DAHDI/i1/1234567-4a7f", "") in new stack
> == Channel 'DAHDI/i1/1234567-4a7f' jumping out of macro
> 'call-from-outside'
> -- Executing [s at macro-recurse_check_redirect_not_mailbox:7]
> While("DAHDI/i1/1234567-4a7f", "1") in new stack
>
> I checked the while-endwhile balance and it seems ok.
> I also checked if I GoTo() outside the loop. I don't.
>
> Macroexit is executed inside the while-endwhile loop in certain cases
> exiting some inner loop.
>
> Could MacroExiting inside a while loop cause this lost of balance?
>
>
Yes it could. A While loop should be terminated with an EndWhile.
Both the While application as well as the Macro application attempt to
control the PBX flow while a channel is executing within them. Terminating
an outer container of PBX flow without properly terminating an inner one
can inbalance the stack.
And just as a reminder, Macros are deprecated. They tend to have odd side
effects at times, and overly nesting Macros can result in a crash. You
should consider switching to subroutines.
Matt
--
Matthew Jordan
Digium, Inc. | Director of Technology
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20151130/b3ccda2d/attachment.html>
More information about the asterisk-users
mailing list