Mitch Thompson wrote:
[SATX_555_Extensions]

exten => 1212,1,System(cat /tmp/{orig_num}) ; ${orig_num} is set at the beginning of [from-trunk-custom] to the full dialed digits in ${EXTEN}, before I break it down. exten => 1212,n,Busy(); if the file exists, someone else has already called this number, return busy

exten => 1212,102,System(echo ${UNIQUEID} > /tmp/${orig_num}) ; basically, create a file in /tmp whose name is the full number from the beginning. In this case, the full ; filename would be /tmp/2105551212. I don't really care about the contents, though. exten => 1212,103, Goto(Idle,1) ; from here, we jump to a new extension called Idle, where we do a Random to decide whether to simulate no one home (ring no answer) or ; we send ring for about 10 seconds, then Answer() and play some .wav files, then hangup. The last thing we do in either case is to delete ; the /tmp/${orig_num} file.

The above code works very well at low call volumes. However, I'm running into race conditions at high call volumes where several calls are getting through the test in priority 1 before the file is created in priority 102 (n+101).


Here's what I would do...

First, no System calls.  Stay within asterisk.

I doubt this will get rid of all race conditions, but I imagine it would at least reduce them.

exten => 1212,1,GotoIf($["${DB(/tmp/${orig_num})}" != "${UNIQUEID}"]?abort)
exten => 1212,1,Set(${DB(/tmp/${orig_num})}=${UNIQUEID})
exten => 1212,n,GotoIf($["${DB(/tmp/${orig_num})}" != "${UNIQUEID}"]?abort)
exten => 1212,n, Goto(Idle,1)

exten => 1212,n(abort),Busy()

Regards,
Trevor
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --

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

Reply via email to