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








<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On January 9th, 2012, 6:13 a.m., <b>schmidts</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/1655/diff/2/?file=22864#file22864line1674" style="color: black; font-weight: bold; text-decoration: underline;">/trunk/main/channel.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="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
   <td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static int ast_channel_by_uniqueid_cb(void *obj, void *arg, void *data, int flags)</pre></td>

  </tr>
 </tbody>




 
 



 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1468</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="kt">int</span> <span class="n">ret</span> <span class="o">=</span> <span class="n">CMP_MATCH</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;">see comment above, CMP_MATCH &amp; CMP_STOP</pre>
 </blockquote>



 <p>On January 9th, 2012, 8:38 a.m., <b>Terry Wilson</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I prefer to let the caller choose via flags whether or not to continue searching for other matches. If they don&#39;t specifically pass OBJ_MULTIPLE, I think CMP_MATCH implies stopping. Maybe I should specifically pass 0 for flags when ast_channel_by_uniqueid_cb is called from ast_channel_cmp_cb?</pre>
 </blockquote>





 <p>On January 9th, 2012, 11:10 a.m., <b>Mark Michelson</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <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 no reason to set OBJ_MULTIPLE when calling by uniqueid. When OBJ_MULTIPLE is not supplied, then CMP_MATCH implies CMP_STOP, but it doesn&#39;t hurt to have CMP_MATCH | CMP_STOP there. I find it&#39;s more expressive, plus (imho) the callback shouldn&#39;t be aware what flags have been set and should act based on how it knows its relevant data behaves.</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;">To me, it seems limiting. I like trusting the caller to know what they really want. For example, let&#39;s say you wanted to write a test that determines whether or not your uniqueid is &quot;sufficiently unique&quot;. Normal code would never call with OBJ_MULTIPLE, but the test code could to find out if there really were more than one match. The only thing you end up doing is limiting what the caller can do with the code. The callback, in this way, can be truly agnostic about the flags and just do what the caller wants and not impose its view of the the world on things. Just my opinion, anyway. If other people feel differently, I am amenable to change.
</pre>
<br />




<p>- Terry</p>


<br />
<p>On January 6th, 2012, 3:51 p.m., Terry Wilson wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/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 Terry Wilson.</div>


<p style="color: grey;"><i>Updated Jan. 6, 2012, 3:51 p.m.</i></p>




<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;">There would be many benefits to making the ast_channel an opaque handle, from increasing maintainability to presenting ways to kill masquerades. I propose that we kick things off by taking things a field at a time, renaming the field to &#39;__do_not_use_${fieldname}&#39; and then writing setters/getters and converting the existing code to using them. When all fields are done, we can move ast_channel to a C file from channel.h and lop off the &#39;__do_not_use_&#39;.

This patch sets up main/channel_interal_api.c to be the only file that actually accesses the ast_channel&#39;s fields directly. The intent would be for any API functions in channel.c to use the accessor functions. No more monkeying around with channel internals. We should use our own APIs.

The interesting changes in this patch are the addition of channel_internal_api.c, the moving of the AST_DATA stuff from channel.c to channel_internal_api.c (note: the AST_DATA stuff will have to be reworked to use accessor functions when ast_channel is really opaque), and some re-working of the way channel iterators/callbacks are handled so as to avoid creating fake ast_channels on the stack to pass in matching data by directly accessing fields (since &quot;name&quot; is a stringfield and the fake channel doesn&#39;t init the stringfields, you can&#39;t use the ast_channel_name_set() function). I went with ast_channel_name(chan) for a getter, and ast_channel_name_set(chan, name) for a setter.

Ideas welcome!

The majority of the grunt-work for this change was done by writing a semantic patch using Coccinelle ( http://coccinelle.lip6.fr/ ).

note: There are some extra changes to some of the h323 files to comment out variables that were set and not used so that I could get it to compile under dev-mode.
</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;">I ran it through the testsuite and seemed to get the same number of failures that I got without it. I also made some calls and tested out &#39;core show channel &lt;tab&gt;&#39; and &#39;core show channel Console/dsp&#39;, and core show channels to make sure that the changes to the iterators seemed to work.</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/addons/chan_mobile.c <span style="color: grey">(349871)</span></li>

 <li>/trunk/addons/chan_ooh323.c <span style="color: grey">(349871)</span></li>

 <li>/trunk/addons/ooh323c/src/memheap.c <span style="color: grey">(349871)</span></li>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 <li>/trunk/bridges/bridge_multiplexed.c <span style="color: grey">(349871)</span></li>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 <li>/trunk/channels/chan_vpb.cc <span style="color: grey">(349871)</span></li>

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

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

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

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

 <li>/trunk/funcs/func_audiohookinherit.c <span style="color: grey">(349871)</span></li>

 <li>/trunk/funcs/func_channel.c <span style="color: grey">(349871)</span></li>

 <li>/trunk/funcs/func_frame_trace.c <span style="color: grey">(349871)</span></li>

 <li>/trunk/funcs/func_global.c <span style="color: grey">(349871)</span></li>

 <li>/trunk/funcs/func_groupcount.c <span style="color: grey">(349871)</span></li>

 <li>/trunk/funcs/func_lock.c <span style="color: grey">(349871)</span></li>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 <li>/trunk/res/snmp/agent.c <span style="color: grey">(349871)</span></li>

</ul>

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




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








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