[asterisk-users] Macro vs sub

Matthew Jordan mjordan at digium.com
Wed Jan 18 06:51:03 CST 2012



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

> From: "Jonas Kellens" <jonas.kellens at telenet.be>
> To: "Asterisk Users Mailing List - Non-Commercial Discussion"
> <asterisk-users at lists.digium.com>
> Sent: Wednesday, January 18, 2012 6:36:35 AM
> Subject: Re: [asterisk-users] Macro vs sub

> Thank you for sharing your experience.

> Anyone else ? Maybe one of the developers can confirm this risk of
> working with macros ?

I don't think you need an Asterisk developer to tell you the risks of using macros in deeply nested situations.  Quoting the documentation of Macro:

"Because of the way Macro is implemented (it executes the priorities contained within it via sub-engine), and a fixed per-thread memory stack allowance, macros are limited to 7 levels of nesting (macro calling macro calling macro, etc.); It may be possible that stack-intensive applications in deeply nested macros could cause asterisk to crash earlier than this limit. It is advised that if you need to deeply nest macro calls, that you use the Gosub application (now allows arguments like a Macro) with explict Return() calls instead."

> I'm now also moving towards GoSub where possible. I was experiencing
> asterisk restarts every 40minutes. Exactly 40 minutes ! I've created
> a backtrace of the core dump file but have not had any reaction (and
> I myself don't understand the content of the backtrace)

> Jonas.

> On 01/18/2012 01:27 PM, Sammy Govind wrote:
> > Yes I've personally experienced issue with nested macros and
> > eventually asterisk failing to process call any further. So I moved
> > onto using GoSUBs and everything worked perfectly. Since then I'm
> > using GoSUBs happily.
> 

> > On Wed, Jan 18, 2012 at 4:54 PM, Jonas Kellens <
> > jonas.kellens at telenet.be > wrote:
> 

> > > Can someone confirm that the nesting of macro's or the continuous
> > > and
> > > simultaneous use of different macro's, can lead to stack-problems
> > > and cause an Asterisk spontaneous reboot/restart ?
> > 
> 

> > > Kind regards,
> > 
> 
> > > Jonas.
> > 
> 

> > > On 01/17/2012 03:02 PM, Bryant Zimmerman wrote:
> > 
> 
> > > > Jonas
> > > 
> > 
> 

> > > > >From what I understand they are trying to phase out Macros. We
> > > > >are
> > > > >slowly removing them from our dialplans as time allows for
> > > > >testing.
> > > 
> > 
> 

> > > > Thanks
> > > 
> > 
> 

> > > > Bryant Zimmerman (ZK Tech Inc.)
> > > 
> > 
> 
> > > > 616-855-1030 Ext. 2003
> > > 
> > 
> 

> > > > From : "Jonas Kellens" <jonas.kellens at telenet.be>
> > > 
> > 
> 
> > > > Sent : Tuesday, January 17, 2012 5:53 AM
> > > 
> > 
> 
> > > > To : "Asterisk Users Mailing List - Non-Commercial Discussion"
> > > > <asterisk-users at lists.digium.com>
> > > 
> > 
> 
> > > > Subject : [asterisk-users] Macro vs sub
> > > 
> > 
> 

> > > > Hello list,
> > > 
> > 
> 

> > > > can I conclude that it is better to use sub's in stead of
> > > > macro's
> > > > ?
> > > 
> > 
> 

> > > > I read the following in an Asterisk-book :
> > > 
> > 
> 

> > > > GoSub() works in a different manner from Macro(), though, in
> > > > that
> > > > it
> > > > doesn’t have the stack space requirements, so
> > > 
> > 
> 
> > > > it nests effectively. Essentially, GoSub() acts like Goto()
> > > > with
> > > > a
> > > > memory of where it came from.
> > > 
> > 
> 

> > > > Is it then not better to use a method that does not stack ?!
> > > 
> > 
> 

> > > > Kind regards,
> > > 
> > 
> 

> > > > Jonas.
> > > 
> > 
> 

> > > > --
> > > 
> > 
> 
> > > > _____________________________________________________________________
> > > 
> > 
> 
> > > > -- Bandwidth and Colocation Provided by
> > > > http://www.api-digital.com
> > > > --
> > > 
> > 
> 
> > > > New to Asterisk? Join us for a live introductory webinar every
> > > > Thurs:
> > > > http://www.asterisk.org/hello asterisk-users mailing list
> > > 
> > 
> 
> > > > To UNSUBSCRIBE or update options visit:
> > > > http://lists.digium.com/mailman/listinfo/asterisk-users
> > > 
> > 
> 
> > > --
> > 
> 
> > > _____________________________________________________________________
> > 
> 
> > > -- Bandwidth and Colocation Provided by
> > > http://www.api-digital.com
> > > --
> > 
> 
> > > New to Asterisk? Join us for a live introductory webinar every
> > > Thurs:
> > 
> 
> > > http://www.asterisk.org/hello
> > 
> 

> > > asterisk-users mailing list
> > 
> 
> > > To UNSUBSCRIBE or update options visit:
> > 
> 
> > > http://lists.digium.com/mailman/listinfo/asterisk-users
> > 
> 

> > --
> 
> > _____________________________________________________________________
> 
> > -- Bandwidth and Colocation Provided by http://www.api-digital.com
> > --
> 
> > New to Asterisk? Join us for a live introductory webinar every
> > Thurs:
> > http://www.asterisk.org/hello asterisk-users mailing list
> 
> > To UNSUBSCRIBE or update options visit:
> > http://lists.digium.com/mailman/listinfo/asterisk-users
> 



More information about the asterisk-users mailing list