Trevor Peirce wrote:
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
Trevor,

Thank you very much for your response. Yes, I was worried about the performance hit of the System() call, but as I said, I tried doing it with Global and/or local variables, and just wound up confusing myself. I'm not a programmer by trade or nature, so I knew up front it was "dirty code". Your method of staying with Asterisk looks like something I can easily switch to in one exchange context and give it a quick try.

Thanks again!

--
Read The Patriot   It's Right -- It's Free
http://PatriotPost.US/subscribe/
--
Mitch Thompson, San Antonio, Texas//WB5UZG
Red Hat Certified Engineer

_______________________________________________
--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