[prev in list] [next in list] [prev in thread] [next in thread] 

List:       asterisk-dev
Subject:    Re: [asterisk-dev] [Code Review] Make new SIP work make use of threadpool
From:       "Pedro Kiefer" <reviewboard () asterisk ! org>
Date:       2013-01-31 19:23:08
Message-ID: 20130131192308.8494.60033 () hotblack ! digium ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2305/#review7784
-----------------------------------------------------------


Just my 2 cents.


/team/group/pimp_my_sip/channels/chan_gulp.c
<https://reviewboard.asterisk.org/r/2305/#comment14768>

    If the responde code was assigned from a defined value, I think the rea=
dability of the code would improve a great deal.


- Pedro


On Jan. 31, 2013, 1:01 p.m., Mark Michelson wrote:
> =

> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2305/
> -----------------------------------------------------------
> =

> (Updated Jan. 31, 2013, 1:01 p.m.)
> =

> =

> Review request for Asterisk Developers, Matt Jordan and jcolp.
> =

> =

> Summary
> -------
> =

> This changeset introduces threadpool usage into the new SIP work. Functio=
n calls that originate from the Asterisk core (such as channel callbacks) a=
nd from PJSIP's event handling thread (such as incoming request/response ca=
llbacks) now push their work into the SIP threadpool.
> =

> The benefits to this changeset are:
> 1) Frees up PJSIP event handling threads so that they can process more in=
coming SIP messages at a time
> 2) Places similar SIP tasks into their own task queue so that they can be=
 completed in sequence, thus limiting resource contention. So far, session =
tasks are the only ones that use this mechanism
> =

> I added a new API call called ast_sip_push_task_synchronous(), that allow=
s for you to push a task to a servant and block until the task completes. T=
his is used in several cases where Asterisk threads need to make use of a P=
JSIP feature but need to have the result of the pushed task before returnin=
g. A good example of this is gulp_request() in chan_gulp. We need to call s=
ome PJSIP routines to set up a UAC and a dialog and such. But we also need =
to return a new ast_channel before gulp_request() returns.
> =

> Please have a look over this to see if I've made any obvious mistakes (e.=
g. memory leaks, tasks being not being executed in the threadpool when they=
 should be)
> =

> =

> Diffs
> -----
> =

>   /team/group/pimp_my_sip/channels/chan_gulp.c 380670 =

>   /team/group/pimp_my_sip/include/asterisk/res_sip.h 380670 =

>   /team/group/pimp_my_sip/include/asterisk/res_sip_session.h 380670 =

>   /team/group/pimp_my_sip/include/asterisk/threadpool.h 380670 =

>   /team/group/pimp_my_sip/main/taskprocessor.c 380670 =

>   /team/group/pimp_my_sip/main/threadpool.c 380670 =

>   /team/group/pimp_my_sip/res/res_sip.c 380670 =

>   /team/group/pimp_my_sip/res/res_sip.exports.in 380670 =

>   /team/group/pimp_my_sip/res/res_sip/config_transport.c 380670 =

>   /team/group/pimp_my_sip/res/res_sip/sip_options.c 380670 =

>   /team/group/pimp_my_sip/res/res_sip_session.c 380670 =

> =

> Diff: https://reviewboard.asterisk.org/r/2305/diff
> =

> =

> Testing
> -------
> =

> I've run the OPTIONS test in the testsuite and can confirm that Asterisk =
shutdown does not crash Asterisk any more. I also ran incoming and outgoing=
 calls and ensured that they completed correctly with no issue.
> =

> =

> Thanks,
> =

> Mark
> =

>


[Attachment #5 (text/html)]

<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/2305/">https://reviewboard.asterisk.org/r/2305/</a>
  </td>
    </tr>
   </table>
   <br />





 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Just my 2 cents.</pre>  \
<br />





<div>




<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/2305/diff/1/?file=33189#file33189line382" \
style="color: black; font-weight: bold; text-decoration: \
underline;">/team/group/pimp_my_sip/channels/chan_gulp.c</a>  <span \
style="font-weight: normal;">

     (Diff revision 1)

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

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

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static \
int gulp_write(struct ast_channel *ast, struct ast_frame *frame)</pre></td>

  </tr>
 </tbody>



 
 




 <tbody>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2">298</font></th>  <td bgcolor="#fdfebc" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; ">			<span \
class="n">status</span> <span class="o">=</span> <span \
class="n">pjsip_inv_answer</span><span class="p">(</span><span \
class="n">session</span><span class="o">-&gt;</span><span \
class="n">inv_session</span><span class="p">,</span> <span class="mi">180</span><span \
class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span \
class="nb">NULL</span><span class="p">,</span> <span class="o">&amp;</span><span \
class="n">packet</span><span class="p">);</span></pre></td>  <th bgcolor="#e9eaa8" \
style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" \
align="right"><font size="2">364</font></th>  <td bgcolor="#fdfebc" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; ">			<span \
class="n">response_code</span> <span class="o">=</span> <span \
class="mi">180</span><span class="p">;</span></pre></td>  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">If the \
responde code was assigned from a defined value, I think the readability of the code \
would improve a great deal.</pre> </div>
<br />



<p>- Pedro</p>


<br />
<p>On January 31st, 2013, 1:01 p.m., Mark Michelson wrote:</p>






<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, Matt Jordan and jcolp.</div>
<div>By Mark Michelson.</div>


<p style="color: grey;"><i>Updated Jan. 31, 2013, 1:01 p.m.</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;">This changeset introduces threadpool usage into the new SIP work. \
Function calls that originate from the Asterisk core (such as channel callbacks) and \
from PJSIP&#39;s event handling thread (such as incoming request/response callbacks) \
now push their work into the SIP threadpool.

The benefits to this changeset are:
1) Frees up PJSIP event handling threads so that they can process more incoming SIP \
messages at a time 2) Places similar SIP tasks into their own task queue so that they \
can be completed in sequence, thus limiting resource contention. So far, session \
tasks are the only ones that use this mechanism

I added a new API call called ast_sip_push_task_synchronous(), that allows for you to \
push a task to a servant and block until the task completes. This is used in several \
cases where Asterisk threads need to make use of a PJSIP feature but need to have the \
result of the pushed task before returning. A good example of this is gulp_request() \
in chan_gulp. We need to call some PJSIP routines to set up a UAC and a dialog and \
such. But we also need to return a new ast_channel before gulp_request() returns.

Please have a look over this to see if I&#39;ve made any obvious mistakes (e.g. \
memory leaks, tasks being not being executed in the threadpool when they should \
be)</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&#39;ve run the OPTIONS test in the testsuite and can confirm that \
Asterisk shutdown does not crash Asterisk any more. I also ran incoming and outgoing \
calls and ensured that they completed correctly with no issue.</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>/team/group/pimp_my_sip/channels/chan_gulp.c <span style="color: \
grey">(380670)</span></li>

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

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

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

 <li>/team/group/pimp_my_sip/main/taskprocessor.c <span style="color: \
grey">(380670)</span></li>

 <li>/team/group/pimp_my_sip/main/threadpool.c <span style="color: \
grey">(380670)</span></li>

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

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

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

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

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

</ul>

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




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








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



--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic