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








<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On May 27th, 2011, 6 p.m., <b>Russell Bryant</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  



<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/1229/diff/2/?file=16675#file16675line10518" style="color: black; font-weight: bold; text-decoration: underline;">trunk/main/pbx.c</a>
    <span style="font-weight: normal;">

     (Diff revision 2)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
   <td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">int ast_pbx_exten_parse(struct ast_channel *chan, const char *goto_target, char *context, int context_len, char *exten, int exten_len, char *priority, int priority_len)</pre></td>

  </tr>
 </tbody>




 
 



 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">10518</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">int ast_pbx_exten_run(struct ast_channel *chan, const char *context, const char *exten, int priority, int restore_dialplan_location, int continue_on_hangup)</pre></td>
  </tr>

 </tbody>

</table>

  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Why is this function needed?  Is there anything wrong with just doing this the way the GoSub() option for app_dial works?</pre>
 </blockquote>



 <p>On May 28th, 2011, 12:07 p.m., <b>kobaz</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">There&#39;s another patch (hangup handlers) that also needs to run dialplan on a channel.  This was my way of abstracting the specific functionality that was needed from __ast_pbx_run.  Once everyone was happy with ast_pbx_exten_run, the plan was to put in another patch that removed the duplicated code from __ast_pbx_run and call ast_pbx_exten_run instead.

But I do like your idea better.  Executing GoSub would accomplish the same thing it seems.</pre>
 </blockquote>







</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Search for ast_pbx_run_args() in app_dial.c.  That will take you to how the &quot;run GoSub() on answer&quot; options work.</pre>
<br />




<p>- Russell</p>


<br />
<p>On May 24th, 2011, 3:38 p.m., kobaz wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.orgrb/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 2011-05-24 15:38:57</i></p>




<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/abc)
  SIP/abc-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.
  &#39;PreDial&#39; new option &#39;I&#39; 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,,I(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 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&#39;t do it right away

Meanwhile... SIP/234 zips right by, lock &#39;foo&#39; 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 =&gt; {
    UNLOCK(foo);
  }
}

Now, under no circumstances can this dialplan be run through and execute the Dial unless lock &#39;foo&#39; is released.

Obviously this doesn&#39;t ensure that you&#39;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 =&gt; {
    NoOp(I&#39;m Here!);
  }
}

 Dial(SIP/def,,I(predial,s,1))
   run predial on callee channel

 Dial(SIP/def&amp;SIP/ghi&amp;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> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>trunk/apps/app_dial.c <span style="color: grey">(320708)</span></li>

 <li>trunk/include/asterisk/pbx.h <span style="color: grey">(320708)</span></li>

 <li>trunk/main/pbx.c <span style="color: grey">(320708)</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>