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










<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On June 6th, 2013, 8:34 a.m. CDT, <b>David Lee</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  



<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/2596/diff/2/?file=39176#file39176line283" style="color: black; font-weight: bold; text-decoration: underline;">trunk/main/stasis_cache.c</a>
    <span style="font-weight: normal;">

     (Diff revision 2)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">struct ao2_container *stasis_cache_dump(struct stasis_caching_topic *caching_topic, struct stasis_message_type *type)</pre></td>

  </tr>
 </tbody>



 
 

 <tbody>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">282</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">        </span><span class="cm">/* strcpy safe */</span></pre></td>
    <th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">275</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">        </span><span class="n">msg</span> <span class="o">=</span> <span class="n">stasis_message_create</span><span class="p">(</span><span class="n">stasis_cache_clear_type</span><span class="p">(),</span> <span class="n">cached_msg</span><span class="p">);</span></pre></td>
  </tr>

 </tbody>

</table>

  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">There&#39;s a potential problem with pulling the snapshot from the cache instead of creating the snapshot fresh.

Since the cache updates happen asynchronously in the Stasis thread pool, this could be an old snapshot. Not a problem currently, but will be if someone tries to use that snapshot as the final state of the object.

What&#39;s more problematic is that for a very short lived object, it may attempt to create the cache_clear message before there&#39;s an entry in the cache. Then the clear creation will fail, and the cache will have a ZOMBIE SNAPSHOT THAT WILL NOT DIE.</pre>
 </blockquote>





</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Changed to final snapshot creation.</pre>
<br />




<p>- opticron</p>


<br />
<p>On June 6th, 2013, 8:21 a.m. CDT, opticron wrote:</p>








<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 and David Lee.</div>
<div>By opticron.</div>


<p style="color: grey;"><i>Updated June 6, 2013, 8:21 a.m.</i></p>









<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;">This reworks the stasis cache clear mechanism such that an actual snapshot message is published inside of the cache clear message instead of the stasis_cache_clear structure (the ID and message type) which has been removed.  This allows multiple caches to consume the same clear message and avoids the problems of needing to clear unknown secondary caches which may be keyed on different parts of the snapshot.

This also resolves an issue where a channel snapshot could be cleared from the channel snapshot cache multiple times if multiple threads called ast_hangup on the channel at the same time.

This also resolves an issue where an endpoint snapshot was published after it was cleared from the cache, thus repopulating it in the cache.</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/include/asterisk/stasis.h <span style="color: grey">(390501)</span></li>

 <li>trunk/main/bridging.c <span style="color: grey">(390501)</span></li>

 <li>trunk/main/channel.c <span style="color: grey">(390501)</span></li>

 <li>trunk/main/endpoints.c <span style="color: grey">(390501)</span></li>

 <li>trunk/main/stasis_cache.c <span style="color: grey">(390501)</span></li>

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

</ul>

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







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








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