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



<table bgcolor="#e0e0e0" width="100%" cellpadding="8" style="border: 1px gray solid;">
 <tr>
  <td>
   <h1 style="margin-right: 0.2em; padding: 0; font-size: 10pt;">This change has been marked as submitted.</h1>
  </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 and rmudgett.</div>
<div>By Tzafrir Cohen.</div>


<p style="color: grey;"><i>Updated June 23, 2014, 2:44 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;">Committed in revision 417059</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-23554">ASTERISK-23554</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;">Issue: when a PRI span is disconnected (e.g.: following the unassignment pri spans) dahdi channels of that span can be destroyed in two different pathes:

1. DAHDI channels are destroyed in response to pri_event_removed
2. The span is destroyed in response to DAHDI_EVENT_REMOVED in the D-channel. Before the span is destroyed, its channels need to be destroyed.

If the channel is not in a call, (1) is run from the monitor thread, holding the iflock (lock of iflist: the list of channels). somewhere in the process of destroying a channel that belongs to a PRI
span, the pri's lock needs to be acquired.

(2) is called from a context of handling the PRI events and hence holds the PRI lock. Destroying the channels requires getting the iflock.

Which means that if the two happen simultaneously, we have a deadlock. And the two will happen simultaneously, as recent versions of DAHDI will send an extra DAHDI_EVENT_REMOVED as a response to any call to the ioctl on DAHDI_GET_EVENT on a removed span.

This review includes the patches pri_destroy_span_prilist.patch and sigpri_handle_enodev_1.patch from the referred bug. The former solves this deadlock by creating a list of spans to be removed "later" and and thus allow executing (2) without holding the pri lock.

The second patch fixes error handling of libpri: if read returns -ENODEV, we have no device and it should be destroyed. This, however, requires exposing the above "deferred destruction" functionality to sig_pri.


</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/channels/sig_pri.c <span style="color: grey">(416446)</span></li>

 <li>/trunk/channels/sig_pri.h <span style="color: grey">(416446)</span></li>

 <li>/trunk/channels/chan_dahdi.c <span style="color: grey">(416446)</span></li>

</ul>

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







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




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