<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/1229/">https://reviewboard.asterisk.org/r/1229/</a>
</td>
</tr>
</table>
<br />
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By kobaz.</div>
<p style="color: grey;"><i>Updated Nov. 5, 2011, 10:22 a.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Changes</h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Minor changes:
- Removed todo to parse gosub arguments (it's supported now)
- Updated patch to be against latest trunk (343488).
- Removed some trailing tabs/spaces
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">PreDial
Say SIP/abc is calling SIP/def
You have: Dial(SIP/def)
SIP/def-123234 is created. But how can you tell that from dialplan?
You can use a pickup macro: M or U options to Dial(), but you have to wait till pickup to know.
'PreDial' new option 'b' to Dial(), will let you run dialplan on the newly created channel before it is connected to the end-device.
New way:
Dial(SIP/def,,b(predial,s,1))
Dialplan will run on SIP/def-123234 and allow you to know right away what channel will be used, and you can set specific variables on that channel.
You can also run dialplan on the caller channel (option 'B') right before the dial, which is a great place to do a last microsecond UNLOCK to ensure good channel behavior.
Example: LOCK(foo)
do stuff
UNLOCK(foo)
Dial(SIP/abc)
With this above example, say SIP/123 and SIP/234 are running this dialplan.
SIP/123 locks foo
SIP/123 unlocks foo
due to some cpu load issue, SIP/123 takes its time getting to Dial(SIP/abc) and doesn't do it right away
Meanwhile... SIP/234 zips right by, lock 'foo' is already unlocked, it grabs the lock, does its thing and it gets to Dial(SIP/abc). SIP/123 wakes up and finally gets to the Dial(). Now you have two channels dialing SIP/abc when there was supposed to be one.
If your intention is to ensure that Dial(SIP/abc) is only done one at a time, you may have unexpected behavior lurking.
New way:
LOCK(foo)
do stuff
Dial(SIP/abc,,B(unlock,s,1))
context unlock {
s => {
UNLOCK(foo);
}
}
Now, under no circumstances can this dialplan be run through and execute the Dial unless lock 'foo' is released.
Obviously this doesn't ensure that you're not calling SIP/abc more than once (you would need more dialplan logic for that), but it will allow a dialplan coder to also put the Dial in the locked section to ensure tighter control.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">context predial {
s => {
NoOp(I'm Here!);
}
}
Dial(SIP/def,,I(predial,s,1))
run predial on callee channel
Dial(SIP/def&SIP/ghi&SIP/qrx,,I(predial,s,1))
runs predial on all three callee channels
Dial(SIP/def,,B(predial,s,1))
runs predial on caller channel
Dial(SIP/def,,B(predial,s,1)I(predial,s,1))
runs predial on callee channel and caller channel</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> (updated)</h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>trunk/apps/app_dial.c <span style="color: grey">(343488)</span></li>
<li>trunk/include/asterisk/pbx.h <span style="color: grey">(343488)</span></li>
<li>trunk/main/pbx.c <span style="color: grey">(343488)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1229/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>