[asterisk-dev] Call priority and Dial()

Andrew Kohlsmith akohlsmith-asterisk at benshaw.com
Tue Sep 5 05:12:35 MST 2006


I've opened up bug 7882: http://bugs.digium.com/view.php?id=7882

Now seeing as (as far as I can tell) it involves adding a variable to the 
channel structure, I'd like to get some input from the developers before I 
put a lot of blood, sweat and tears into solving this particular issue.

I know that messing around with ast_channel can only be done when all other 
options are evaluated; that's what this thread has been started for.

Essentially what I am trying to do is allow Dial() to terminate a 
lower-priority call in order to place a higher-priority one if and only if 
there are no available channels.  This can currently be done in a hackish way 
with an AGI or perhaps even the Manager interface, but race conditions 
abound.  If I can put this in app_dial I can eliminate a lot of headaches.

Another way to achieve this would be to create a set of dialplan functions 
which would allow the dialplan to snoop the channel variables of *any* 
channel in the system.  However the security implications of this aren't to 
be taken lightly, and the race conditions still exist.

My theoretical way of doing this WITHOUT playing with app_dial is to use a 
channel variable and a global dialplan variable, a dialer macro which is used 
for ALL outgoing calls, and an AGI:  [macro-dialout] checks to see if the 
global variable ${EMERGENCY_MODE} is set and if so, does not allow any 
outgoing calls unless the channel variable ${EMERGENCY_CALL} is set.  An 
emergency call sets ${EMERGENCY_CALL} before Macro(dialout,911) is executed.  
The macro sets ${EMERGENCY_MODE} if ${EMERGENCY_CALL} is set, and 
ChanIsAvail()s the normal outgoing channel "set" (think Zap/g1 for example).  
If a channel is available, it places the call.  If a channel is NOT 
available, the AGI must scan all of the channels that it would normally place 
an emergency call through and if ${EMERGENCY_CALL} is not set, soft hangup 
the channel and dial the emergency call.

${EMERGENCY_MODE} needs to be UN-set at some point to allow more calls once 
the emergency call is in-progress, but it cannot be set until AFTER the 
Dial() is done to prevent a race condition (when the soft hung-up channel is 
freed but another non-emergency call "steals" the channel) -- that's what the 
${EMERGENCY_MODE} global variable is for, but it's a little brutal...

Thoughts?

-A.



More information about the asterisk-dev mailing list