<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/2355/">https://reviewboard.asterisk.org/r/2355/</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 and Joshua Colp.</div>
<div>By Mark Michelson.</div>


<p style="color: grey;"><i>Updated Feb. 25, 2013, 8:53 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;">Added sip_distributor.c</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;">The pool_shark branch was created to make the new SIP work make use of the threadpool. This set of changes improves upon the first set of changes by making things easier for people who write PJSIP modules. The changes are detailed below:

* The ast_sip_work structure and some of its methods have been removed in favor of the generic task serializer.

* A PJSIP module, the message distributor, has been added. This module has a high priority and gets called into after the PJSIP transport layer but before the PJSIP transaction layer. The distributor is used as a means of moving an incoming message from a PJSIP thread into a SIP servant thread. Then from the SIP servant thread, the message bubbles up through the PJSIP transaction layer, PJSIP dialog layer, and any relevant PJSIP modules that Asterisk has registered. This means that any PJSIP module that registers itself at the transaction layer or higher will have all of its incoming SIP messages already in a SIP servant thread when called back. Unless they need to serialize operations, they do not need to do any special processing to ensure the incoming message is handled in a specific thread. A good example of this is what the SIP OPTIONS handler does in this set of changes.

* Two new PJSIP modules have been added above the dialog layer. The endpoint module and the authenticator module are responsible for doing endpoint lookups and authentication for incoming requests. The placement of these modules means that they are only ever called into for out-of-dialog requests. This means that on an initial INVITE, or on a REGISTER, or on an OPTIONS request, or any other out-of-dialog request, the application-layer modules do not need to worry about endpoint lookup or authentication since that is done already for them. If they need the endpoint, they can call ast_pjsip_rdata_get_endpoint(). For dialog-forming application modules, they will want to save off the endpoint that the endpoint module finds since the endpoint will not be looked up again on in-dialog requests, meaning they will not be able to call ast_pjsip_rdata_get_endpoint().

* Modules that were passing incoming messages off to servants no longer need to do this, so they have been changed not to. So the session module and options module now handle incoming requests in-line rather than pushing them to a servant thread.

* Since it no longer makes sense to pre-allocate a serializer before an ast_sip_session, the functions for allocating SIP sessions has been changed not to take a serializer any more. Instead, the allocation routine creates its own. In addition, the behavior of endpoint references has changed from how it previously was. Now allocating a session results in the endpoint reference count increasing by one rather than having the session inherit the reference passed into it. This makes endpoint reference handling much cleaner, especially in the session module.

* To assist programmers who want to write PJSIP modules in Asterisk, there is a helper method called ast_sip_thread_is_servant() that has been added. It can be used to discern if the thread you currently are in is a SIP servant thread. This means it is not as necessary to dig into the PJSIP internals to know what type of thread you are in when called back. Instead, you can be safe and use this function. This function is currently unused though, since there hasn&#39;t been a need for it yet. This is because all uses of SIP servants where it may be questionable what type of thread we are in need to serialize the task anyway.

* Documentation of the SIP threadpool has been updated.</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;">I have done some regression testing by running some calls in with SIPp and ensuring that the behavior is the same as before I started this work.</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>/team/group/pimp_my_sip/channels/chan_gulp.c <span style="color: grey">(381915)</span></li>

 <li>/team/group/pimp_my_sip/include/asterisk/res_sip.h <span style="color: grey">(381915)</span></li>

 <li>/team/group/pimp_my_sip/include/asterisk/res_sip_session.h <span style="color: grey">(381915)</span></li>

 <li>/team/group/pimp_my_sip/res/pjproject/pjsip/include/pjsip/sip_endpoint.h <span style="color: grey">(381915)</span></li>

 <li>/team/group/pimp_my_sip/res/pjproject/pjsip/src/pjsip/sip_endpoint.c <span style="color: grey">(381915)</span></li>

 <li>/team/group/pimp_my_sip/res/res_sip.c <span style="color: grey">(381915)</span></li>

 <li>/team/group/pimp_my_sip/res/res_sip.exports.in <span style="color: grey">(381915)</span></li>

 <li>/team/group/pimp_my_sip/res/res_sip/config_transport.c <span style="color: grey">(381915)</span></li>

 <li>/team/group/pimp_my_sip/res/res_sip/sip_distributor.c <span style="color: grey">(PRE-CREATION)</span></li>

 <li>/team/group/pimp_my_sip/res/res_sip/sip_options.c <span style="color: grey">(381915)</span></li>

 <li>/team/group/pimp_my_sip/res/res_sip_endpoint_identifier_ip.c <span style="color: grey">(381915)</span></li>

 <li>/team/group/pimp_my_sip/res/res_sip_session.c <span style="color: grey">(381915)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/2355/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>




  </div>
 </body>
</html>