[asterisk-dev] Dialplan - critical sections / semaphores / run-all-of

Tzafrir Cohen tzafrir.cohen at xorcom.com
Thu Jun 8 13:50:10 MST 2006


On Wed, Jun 07, 2006 at 11:34:18PM +0200, Stephen Davies wrote:

> 
> What do you think?
> 
> 2) Guaranteed "run to completion"
> 
> I have fragments of code where I can't have a caller hangup stop
> execution in the middle.  I need to carry on until I get to a "safe"
> point in order to leave the "state" consistent.  A slightly contrived
> example:
> 
>  exten => s,1,Set(DB(credit/${account})=$[${DB(credit/${account})} -
> ${ANSWEREDTIME}])  ; sheesh - $[${oh(my)}goodness]

And if Asterisk crashed here?

>  exten => s,2,Set(DB(used/${account})=$[${DB(used/${account})} +
> ${ANSWEREDTIME}])

So the actual commit must be done here.

You could try to use an external database that guaranntees completion of
transactions. Alternatively, there should be a temporary
database/journal (im-memory) per channel for the local, uncommited, view. 
And all local DB accesses must ask it first.

Or does Berkeley DB has some built-in support for such a thing?

> 
> This doesn't need a mutex lock, but both lines must run if the
> "credit" and "used" are to stay consistent.
> 
> Not sure how best to handle in the dialplan.  Perhaps again a way to
> mark a Macro for this treatment?
> 
> There are ways to dodge around these missing features - calling AGI
> for instance.  But I think they'd add quite a bit of power to the
> dialplan language.

-- 
Tzafrir Cohen      sip:tzafrir at local.xorcom.com
icq#16849755       iax:tzafrir at local.xorcom.com
+972-50-7952406           
tzafrir.cohen at xorcom.com  http://www.xorcom.com



More information about the asterisk-dev mailing list