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

List:       asterisk-dev
Subject:    Re: [asterisk-dev] [Code Review] 4034: chan_pjsip: Fix deadlock when masquerading PJSIP channels.
From:       "rmudgett" <reviewboard () asterisk ! org>
Date:       2014-09-30 19:24:45
Message-ID: 20140930192445.22116.34428 () sonic ! digium ! api
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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

(Updated Sept. 30, 2014, 2:24 p.m.)


Review request for Asterisk Developers.


Changes
-------

Addressed mmichelson's comments.


Bugs: ASTERISK-24356
    https://issues.asterisk.org/jira/browse/ASTERISK-24356


Repository: Asterisk


Description
-------

Performing a directed call pickup resulted in a deadlock when PJSIP channels were \
involved.

A masquerade needs to hold onto the channel locks while it swaps channel information \
between the two channels involved in the masquerade.  With PJSIP channels, the fixup \
routine needed to push a fixup task onto the PJSIP channel's serializer.  \
Unfortunately, if the serializer was also processing a task that needed to lock the \
channel, you get deadlock.

* Added a new control frame that is used to notify the channels that a
masquerade is about to start and when it has completed.

* Added the ability to query supported taskprocessors if the current thread is the
taskprocessor thread.

* Added the ability to suspend/unsuspend the PJSIP serializer thread so a masquerade \
could fixup the PJSIP channel without using the serializer.


Diffs (updated)
-----

  /branches/13/res/res_pjsip_session.exports.in 424175 
  /branches/13/res/res_pjsip_session.c 424175 
  /branches/13/main/taskprocessor.c 424175 
  /branches/13/main/core_unreal.c 424175 
  /branches/13/main/channel.c 424175 
  /branches/13/main/bridge_channel.c 424175 
  /branches/13/include/asterisk/taskprocessor.h 424175 
  /branches/13/include/asterisk/res_pjsip_session.h 424175 
  /branches/13/include/asterisk/frame.h 424175 
  /branches/13/funcs/func_frame_trace.c 424175 
  /branches/13/channels/chan_unistim.c 424175 
  /branches/13/channels/chan_skinny.c 424175 
  /branches/13/channels/chan_sip.c 424175 
  /branches/13/channels/chan_pjsip.c 424175 
  /branches/13/channels/chan_motif.c 424175 
  /branches/13/channels/chan_misdn.c 424175 
  /branches/13/channels/chan_iax2.c 424175 
  /branches/13/addons/chan_ooh323.c 424175 

Diff: https://reviewboard.asterisk.org/r/4034/diff/


Testing
-------

* Performed several directed call pickups without deadlocking.  Before the patch, the \
system would usually deadlock.

* Performed a SIP attended transfer to an appliction.  The transfer still works.


Thanks,

rmudgett


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




<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;">  <tr>
  <td>

<div>Review request for Asterisk Developers.</div>
<div>By rmudgett.</div>


<p style="color: grey;"><i>Updated Sept. 30, 2014, 2:24 p.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;">Addressed mmichelson&#39;s comments.</pre>  </td>
 </tr>
</table>





<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="https://issues.asterisk.org/jira/browse/ASTERISK-24356">ASTERISK-24356</a>


</div>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>


<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;">Performing a directed call pickup resulted in a deadlock when PJSIP \
channels were involved.

A masquerade needs to hold onto the channel locks while it swaps channel information \
between the two channels involved in the masquerade.  With PJSIP channels, the fixup \
routine needed to push a fixup task onto the PJSIP channel&#39;s serializer.  \
Unfortunately, if the serializer was also processing a task that needed to lock the \
channel, you get deadlock.

* Added a new control frame that is used to notify the channels that a
masquerade is about to start and when it has completed.

* Added the ability to query supported taskprocessors if the current thread is the
taskprocessor thread.

* Added the ability to suspend/unsuspend the PJSIP serializer thread so a masquerade \
could fixup the PJSIP channel without using the serializer.</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;">* Performed several directed call pickups without deadlocking.  Before \
the patch, the system would usually deadlock.

* Performed a SIP attended transfer to an appliction.  The transfer still \
works.</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>/branches/13/res/res_pjsip_session.exports.in <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/res/res_pjsip_session.c <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/main/taskprocessor.c <span style="color: grey">(424175)</span></li>

 <li>/branches/13/main/core_unreal.c <span style="color: grey">(424175)</span></li>

 <li>/branches/13/main/channel.c <span style="color: grey">(424175)</span></li>

 <li>/branches/13/main/bridge_channel.c <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/include/asterisk/taskprocessor.h <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/include/asterisk/res_pjsip_session.h <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/include/asterisk/frame.h <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/funcs/func_frame_trace.c <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/channels/chan_unistim.c <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/channels/chan_skinny.c <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/channels/chan_sip.c <span style="color: grey">(424175)</span></li>

 <li>/branches/13/channels/chan_pjsip.c <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/channels/chan_motif.c <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/channels/chan_misdn.c <span style="color: \
grey">(424175)</span></li>

 <li>/branches/13/channels/chan_iax2.c <span style="color: grey">(424175)</span></li>

 <li>/branches/13/addons/chan_ooh323.c <span style="color: grey">(424175)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/4034/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