<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/2427/">https://reviewboard.asterisk.org/r/2427/</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.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Asterisk Developers.</div>
<div>By Alec Davis.</div>








<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-18827">ASTERISK-18827</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;">If the first network message was received before iax2_process_thread() was sleeping, the thread would go to sleep, and sleep forever, with deferred frames banking up.

start_network_thread() creates the initial helper threads and the network_thread at the same time (near enough), with no checks that the helper threads were ready before the network thread was created.

Each iax2_process_thread() is required to be at &#39;ast_cond_wait(&amp;thread-&gt;cond, &amp;thread-&gt;lock)&#39; before any messages can be accepted.
To achieve this, only start the network_thread after each of the helper threads is ready.

The fix is the same method as find_idle_thread() uses when an iax dynamic thread is created, that then waits for the init_cond to be satisfied.</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;">Prior to fix, iax show threads had thread 1 never finishing, with actions = 0, which means it never got processed.
...
Thread 10: state=0, update=6, actions=1, func=&#39;&#39;
Active Threads:
Thread P1: state=1, update=1365045454, actions=0, func=&#39;socket_process&#39;
Dynamic Threads:
10 of 10 threads accounted for with 0 dynamic threads

after fix, works as expected.</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/chan_iax2.c <span style="color: grey">(376441)</span></li>

</ul>

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







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




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