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


<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.orgrb/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 Russell Bryant.</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;">The astobj2 unit tests have been failing in trunk a few times lately.  I still can&#39;t explain the failures, but while reviewing recent changes and trying to think of what could cause a problem, I thought of a case where a recent optimization will break things.  Specifically, this commit:


------------------------------------------------------------------------
r316962 | schmidts | 2011-05-05 02:09:20 -0500 (Thu, 05 May 2011) | 10 lines

Adding the Move to Front Hash functionality

Moving a found object to the front of its bucket to reduce the necessary traversal steps to find an object. This change improves the search time on large system with many data or in link lists.

(closes issue #19233)
Reported by: schmidts

Review: https://reviewboard.asterisk.org/r/1201/
------------------------------------------------------------------------

The complication with this has to do with how astobj2 iterators work.  The iterators are implemented in such a way that you do not have to hold the lock on the container for the entire duration of the container.  The lock is only held while getting the next element.  This works by using some internal version numbers to detect changes to the container while the lock was not held.  As a part of this code, it assumes that the order of elements in a given hash bucket are _always_ ordered by how long they have been in the container.
</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 included new unit test demonstrates the regression.  This test passes in Asterisk 1.8 (where this commit doesn&#39;t exist).  The test fails in trunk with this message:


START  /main/astobj2/ - astobj2_test2 
[test_astobj2.c:astobj2_test_2:481]: iterate take 3, expected &#39;5&#39;, only saw &#39;4&#39; objects
END    /main/astobj2/ - astobj2_test2 Time: &lt;1ms Result: FAIL

After reverting the changes to main/astobj2.c, this test passes in trunk.</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/main/astobj2.c <span style="color: grey">(321657)</span></li>

 <li>/trunk/tests/test_astobj2.c <span style="color: grey">(321657)</span></li>

</ul>

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




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




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