<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/3927/">https://reviewboard.asterisk.org/r/3927/</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 Mark Michelson.</div>


<p style="color: grey;"><i>Updated Aug. 24, 2014, 11:42 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;">Fixed the issue pointed out by Richard.</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-24212">ASTERISK-24212</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;">Several tests in the testsuite had sporadic failures due to crashes that were occurring due to the scheduler. The crash goes something like this:

1) Scheduler thread realizes it's time to send an RTCP packet.
2) Scheduler thread removes RTCP task from the heap so that it can be run.
3) A separate thread ends a call in progress, and attempts to delete the RTCP scheduler task using ast_sched_del().
4) ast_sched_del() cannot find the scheduled task since it is not in the heap (or hashtab in Asterisk 12). This results in a failed assertion.
5) Since the test agents are compiled with DO_CRASH, failing an assertion results in a crash.
6) A crash results in a failed test.

The solution I have crafted here is to maintain a pointer in the scheduler context to which task is currently executing. If we attempt to delete the running task, we wait for it to complete before continuing and return that we successfully deleted the scheduled task.</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;">The test channels/pjsip/basic_calls/two_parties/nominal/alice_initiated/alice_hangs_up was a test that, when I ran it in a loop, would have a test failure typically within about a half hour of starting the test loop. With this patch applied, I no longer see the crash described in the description.

HOWEVER, the test still does occasionally fail, but that's due to a separate race condition involving translation paths not being set up when attempting to perform talk detection. So while the patch attached here may not necessarily be enough to close the referenced issue, it is fixing one of the reasons for test failure.</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/12/main/sched.c <span style="color: grey">(421883)</span></li>

</ul>

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







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




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