<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/2672/">https://reviewboard.asterisk.org/r/2672/</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 David Lee.</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-22002">ASTERISK-22002</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;">In working with res_stasis, I discovered a significant limitation to
the current structure of stasis_caching_topics: you cannot subscribe
to cache updates for a single channel/bridge/endpoint/etc.

To address this, this patch splits the cache away from the
stasis_caching_topic, making it a first class object. The stasis_cache
object is shared amongst individual stasis_caching_topics that are
created per channel/endpoint/etc. These are still forwarded to global
whatever_all_cached topics, so their use from most of the code does
not change.

In making these changes, I noticed that we frequently used a similar
pattern for bridges, endpoints and channels:

     single_topic  ----------------&gt;  all_topic
           ^
           |
     single_topic_cached  ----+----&gt;  all_topic_cached
                              |
                              +----&gt;  cache

This pattern was extracted as the &#39;Stasis Caching Pattern&#39;, defined in
stasis_caching_pattern.h. This avoids a lot of duplicate code between
the different domain objects.

Since the cache is now disassociated from its upstream caching topics,
this also necessitated a change to how the &#39;guaranteed&#39; flag worked
for retrieving from a cache. The code for handling the caching
guarantee was extracted into a &#39;stasis_topic_wait&#39; function, which
works for any stasis_topic.</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;">Tests pass.</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/channel.h <span style="color: grey">(394264)</span></li>

 <li>/trunk/include/asterisk/bridging.h <span style="color: grey">(394264)</span></li>

 <li>/trunk/include/asterisk/app.h <span style="color: grey">(394264)</span></li>

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

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

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

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

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

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

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

 <li>/trunk/apps/confbridge/confbridge_manager.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/apps/app_voicemail.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/apps/app_meetme.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/include/asterisk/channel_internal.h <span style="color: grey">(394264)</span></li>

 <li>/trunk/include/asterisk/devicestate.h <span style="color: grey">(394264)</span></li>

 <li>/trunk/include/asterisk/presencestate.h <span style="color: grey">(394264)</span></li>

 <li>/trunk/include/asterisk/stasis.h <span style="color: grey">(394264)</span></li>

 <li>/trunk/include/asterisk/stasis_bridging.h <span style="color: grey">(394264)</span></li>

 <li>/trunk/include/asterisk/stasis_cache_pattern.h <span style="color: grey">(PRE-CREATION)</span></li>

 <li>/trunk/include/asterisk/stasis_channels.h <span style="color: grey">(394264)</span></li>

 <li>/trunk/include/asterisk/stasis_endpoints.h <span style="color: grey">(394264)</span></li>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 <li>/trunk/main/stasis_cache_pattern.c <span style="color: grey">(PRE-CREATION)</span></li>

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

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

 <li>/trunk/main/stasis_wait.c <span style="color: grey">(PRE-CREATION)</span></li>

 <li>/trunk/res/res_agi.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/res/res_chan_stats.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/res/res_sip_mwi.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/res/res_stasis.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/res/res_xmpp.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/res/stasis/control.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/res/stasis_http/resource_bridges.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/res/stasis_http/resource_channels.c <span style="color: grey">(394264)</span></li>

 <li>/trunk/res/stasis_http/resource_endpoints.c <span style="color: grey">(394264)</span></li>

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

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

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

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

</ul>

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







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




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