<HTML><HEAD>
<META content="text/html; charset=UTF-8" http-equiv=Content-Type></HEAD>
<BODY dir=ltr bgColor=#ffffff text=#000000>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>Hi Daniel,</DIV>
<DIV>Here is the svn diff output against the 3.1.2 version we had in our local 
svn repo for the clear_stats command.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Note I added this as a new command rather than enhancement to the reset one 
to maintain backwards compatibility.</DIV>
<DIV>This version outputs details of the values after resetting them, with the 
old values in brackets so that you can</DIV>
<DIV>a) see if a variable was read only and thus not reset</DIV>
<DIV>b) see the final counts at the point of resetting them all</DIV>
<DIV>&nbsp;</DIV>
<DIV>Also it makes a call to the bodge function get_stat_val_long in this code 
fragment.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Regards</DIV>
<DIV>&nbsp;</DIV>
<DIV>Paul</DIV>
<DIV>&nbsp;</DIV>
<DIV>Index: core_stats.c</DIV>
<DIV>===================================================================</DIV>
<DIV>--- core_stats.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (revision 
8)</DIV>
<DIV>+++ core_stats.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (working 
copy)</DIV>
<DIV>@@ -95,10 +95,12 @@</DIV>
<DIV>&nbsp;</DIV>
<DIV>static struct mi_root *mi_get_stats(struct mi_root *cmd, void 
*param);</DIV>
<DIV>static struct mi_root *mi_reset_stats(struct mi_root *cmd, void 
*param);</DIV>
<DIV>+static struct mi_root *mi_clear_stats(struct mi_root *cmd, void 
*param);</DIV>
<DIV>&nbsp;</DIV>
<DIV>static mi_export_t mi_stat_cmds[] = {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { 
"get_statistics",&nbsp;&nbsp;&nbsp; mi_get_stats,&nbsp;&nbsp;&nbsp; 0&nbsp; 
,&nbsp; 0,&nbsp; 0 },</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { "reset_statistics",&nbsp; 
mi_reset_stats,&nbsp; 0&nbsp; ,&nbsp; 0,&nbsp; 0 },</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { "clear_statistics",&nbsp; 
mi_clear_stats,&nbsp; 0&nbsp; ,&nbsp; 0,&nbsp; 0 },</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { 0, 0, 0, 0, 0}</DIV>
<DIV>};</DIV>
<DIV>&nbsp;</DIV>
<DIV>@@ -207,15 +209,44 @@</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; node = addf_mi_node_child(rpl, 
0, 0, 0, "%s:%s = %lu",</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ZSW(get_stat_module(stat)),</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ZSW(get_stat_name(stat)),</DIV>
<DIV>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
get_stat_val(stat) );</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
get_stat_val_long(stat) );</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (node==0)</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
return -1;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>+inline static int mi_reset_and_add_stat(struct mi_node *rpl, stat_var 
*stat)</DIV>
<DIV>+{</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct mi_node *node;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; long old_val, new_val;</DIV>
<DIV>&nbsp;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (stats_support()==0) return 
-1;</DIV>
<DIV>&nbsp;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
old_val=get_stat_val_long(stat);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reset_stat(stat);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
new_val=get_stat_val_long(stat);</DIV>
<DIV>+</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (old_val==new_val)</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; node = 
addf_mi_node_child(rpl, 0, 0, 0, "%s:%s = %lu",</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ZSW(get_stat_module(stat)),</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nb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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</DIV>
<DIV>+}</DIV>
<DIV>+</DIV>
<DIV>/* callback for counter_iterate_grp_vars. */</DIV>
<DIV>static void mi_add_grp_vars_cbk(void* r, str* g, str* n, counter_handle_t 
h)</DIV>
<DIV>{</DIV>
<DIV>@@ -227,13 +258,43 @@</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
g-&gt;len, g-&gt;s, n-&gt;len, n-&gt;s, counter_get_val(h));</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>+/* callback for counter_iterate_grp_vars to reset counters */</DIV>
<DIV>+static void mi_add_grp_vars_cbk2(void* r, str* g, str* n, counter_handle_t 
h)</DIV>
<DIV>+{</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct mi_node *rpl;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct mi_node *node;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; counter_val_t old_val, 
new_val;</DIV>
<DIV>+</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rpl = r;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; old_val = 
counter_get_val(h);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; counter_reset(h);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new_val = 
counter_get_val(h);</DIV>
<DIV>&nbsp;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (old_val==new_val)</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
node = addf_mi_node_child(rpl, 0, 0, 0, "%.*s:%.*s = %lu",</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
g-&gt;len, g-&gt;s, n-&gt;len, n-&gt;s, new_val);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; node = 
addf_mi_node_child(rpl, 0, 0, 0, "%.*s:%.*s = %lu (%lu)",</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
g-&gt;len, g-&gt;s, n-&gt;len, n-&gt;s, new_val, old_val);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>+}</DIV>
<DIV>+</DIV>
<DIV>+</DIV>
<DIV>/* callback for counter_iterate_grp_names */</DIV>
<DIV>static void mi_add_all_grps_cbk(void* p, str* g)</DIV>
<DIV>{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
counter_iterate_grp_vars(g-&gt;s, mi_add_grp_vars_cbk, p);</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>+/* callback for counter_iterate_grp_names to reset counters */</DIV>
<DIV>+static void mi_add_all_grps_cbk2(void* p, str* g)</DIV>
<DIV>+{</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; counter_iterate_grp_vars(g-&gt;s, 
mi_add_grp_vars_cbk2, p);</DIV>
<DIV>+}</DIV>
<DIV>+</DIV>
<DIV>static struct mi_root *mi_get_stats(struct mi_root *cmd, void *param)</DIV>
<DIV>{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct mi_root *rpl_tree;</DIV>
<DIV>@@ -293,7 +354,66 @@</DIV>
<DIV>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>+static struct mi_root *mi_clear_stats(struct mi_root *cmd, void 
*param)</DIV>
<DIV>+{</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct mi_root *rpl_tree;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct mi_node *rpl;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct mi_node *arg;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
stat_var&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *stat;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; str val;</DIV>
<DIV>&nbsp;</DIV>
<DIV>+</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(stats_support()==0)</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
return init_mi_tree( 404, "Statistics Not Found", 20);</DIV>
<DIV>+</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (cmd-&gt;node.kids==NULL)</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
return init_mi_tree( 400, MI_MISSING_PARM_S, 
MI_MISSING_PARM_LEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
continue;</DIV>
<DIV>+</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
val = arg-&gt;value;</DIV>
<DIV>+</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if ( val.len==3 &amp;&amp; memcmp(val.s,"all",3)==0) {</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
/* add all statistic variables */</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
/* use direct counters access for that */</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
counter_iterate_grp_names(mi_add_all_grps_cbk2, rpl);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
} else if ( val.len&gt;1 &amp;&amp; val.s[val.len-1]==':') {</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
/* add module statistics */</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
val.len--;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
val.s[val.len]=0; /* zero term. */</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
/* use direct counters access for that */</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
counter_iterate_grp_vars(val.s, mi_add_grp_vars_cbk2, rpl);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
val.s[val.len]=':' /* restore */;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
goto error;</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>+</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (rpl-&gt;kids==0) {</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
free_mi_tree(rpl_tree);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
return init_mi_tree( 404, "Statistics Not Found", 20);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>+</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return rpl_tree;</DIV>
<DIV>+error:</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; free_mi_tree(rpl_tree);</DIV>
<DIV>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;</DIV>
<DIV>+}</DIV>
<DIV>+</DIV>
<DIV>+</DIV>
<DIV>static struct mi_root *mi_reset_stats(struct mi_root *cmd, void 
*param)</DIV>
<DIV>{</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct mi_root *rpl_tree;</DIV>
<DIV>&nbsp;</DIV>
<DIV 
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV style="FONT: 10pt tahoma">
<DIV>&nbsp;</DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=miconda@gmail.com 
href="mailto:miconda@gmail.com">Daniel-Constantin Mierla</A> </DIV>
<DIV><B>Sent:</B> Tuesday, March 29, 2011 11:59 AM</DIV>
<DIV><B>To:</B> <A title=paul@crocodile-rcs.com 
href="mailto:paul@crocodile-rcs.com">Paul Pankhurst</A> </DIV>
<DIV><B>Subject:</B> Re: [sr-dev] Fw: 32bit vs 64bit build 
problems</DIV></DIV></DIV>
<DIV>&nbsp;</DIV></DIV>
<DIV 
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">Hi 
Paul,<BR><BR>the return of int instead of long is a bug and I will try to fix 
asap.<BR><BR>The new command to reset statistics is an addition and we can add 
it whenever you want. You don't need to wait for Peter, you can send the patch 
to sr-dev and will be added into the master branch (devel version). Over the 
time, if you plan to contribute more code and come with new patches I can just 
grant you commit access to git, so you can commit directly there, either on 
master branch or your own one and then merge to master.<BR><BR>Thanks,<BR>Daniel 
<BR><BR>On 3/29/11 12:53 PM, Paul Pankhurst wrote: 
<BLOCKQUOTE cite=mid:F00CCAF878E84B9DA94264FF66D1E153@pjplaptop type="cite">
  <DIV dir=ltr>
  <DIV style="FONT-FAMILY: 'Calibri'; COLOR: rgb(0,0,0); FONT-SIZE: 12pt">
  <DIV>Hi Daniel,</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Anything that calls get_stat_val is potentially a problem – I did a 
  ‘bodge’ fix by adding get_stat_val_long function and calling that from 
  kex/core_stats.c instead of get_stat_val. I wasn’t sure if modifying 
  get_stat_val was going to break something else that relied on the return NOT 
  being a long from this function!</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Incidentally I have also extended core_stats.c by adding a 
  clear_statistics mi command that takes the same params as get_statistics, thus 
  allowing users to reset a group or all stats at the same time. My intention is 
  to submit this back to the communits(possibly packaged with Peters presence 
  changes unless you’d prefer them separate)</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Paul</DIV>
  <DIV 
  style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: rgb(0,0,0); FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
  <DIV style="FONT: 10pt tahoma">
  <DIV>&nbsp;</DIV>
  <DIV style="BACKGROUND: rgb(245,245,245)">
  <DIV><B>From:</B> <A title=miconda@gmail.com href="mailto:miconda@gmail.com" 
  moz-do-not-send="true">Daniel-Constantin Mierla</A> </DIV>
  <DIV><B>Sent:</B> Tuesday, March 29, 2011 11:36 AM</DIV>
  <DIV><B>To:</B> <A title=sr-dev@lists.sip-router.org 
  href="mailto:sr-dev@lists.sip-router.org" moz-do-not-send="true">Development 
  mailing list of the sip-router project</A> </DIV>
  <DIV><B>Cc:</B> <A title=paul@crocodile-rcs.com 
  href="mailto:paul@crocodile-rcs.com" moz-do-not-send="true">Paul Pankhurst</A> 
  </DIV>
  <DIV><B>Subject:</B> Re: [sr-dev] Fw: 32bit vs 64bit build 
  problems</DIV></DIV></DIV>
  <DIV>&nbsp;</DIV></DIV>
  <DIV 
  style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: rgb(0,0,0); FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">Hi 
  Paul,<BR><BR>indeed, some of these stats are not consistent. I will go through 
  them. General idea is that the old stats framework will be replaced by a new 
  one (present already in the code) that does not need any kind of locking when 
  updating the counters, thus is faster.<BR><BR>If you have specific examples of 
  current stats that go nuts in 64b, please report them here so I will start 
  with them then I will go through the rest of 
  sources.<BR><BR>Thanks,<BR>Daniel<BR><BR>On 3/29/11 12:04 PM, Paul Pankhurst 
  wrote: 
  <BLOCKQUOTE cite=mid:E7A3523988114F68AED3D320F711621F@pjplaptop type="cite">
    <DIV dir=ltr>
    <DIV style="FONT-FAMILY: 'Calibri'; COLOR: rgb(0,0,0); FONT-SIZE: 12pt">
    <DIV 
    style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: rgb(0,0,0); FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
    <DIV>&nbsp;</DIV></DIV>
    <DIV 
    style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: rgb(0,0,0); FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
    <DIV dir=ltr>
    <DIV style="FONT-FAMILY: 'Calibri'; COLOR: rgb(0,0,0); FONT-SIZE: 12pt">
    <DIV><FONT face="Times New Roman">I have noticed that 'kamctl monitor' 
    displays corrupt statistics when kamailio is built for a 64 bit platform. 
    <BR><BR>Further investigation has revealed that the reason is the underlying 
    datatype is a long, whilst some of the wrapper functions (e.g. get_stat_val) 
    return unsigned int. On a 32bit machine where a long and int are both the 
    same size it is not a problem, but on a 64 bit machine they are different 
    and hence the problem. <BR><BR>Some code uses the wrapper function, other 
    does not, in the case of mi_get_stats it uses both, so depending on 
    paramaters passed to the MI fifo it may work or produce garbage results. 
    </FONT></DIV>
    <DIV><BR>&nbsp;</DIV>
    <DIV>Paul</DIV></DIV></DIV></DIV></DIV></DIV><PRE wrap=""><FIELDSET class=mimeAttachmentHeader></FIELDSET>
_______________________________________________
sr-dev mailing list
<A class=moz-txt-link-abbreviated href="mailto:sr-dev@lists.sip-router.org" moz-do-not-send="true">sr-dev@lists.sip-router.org</A>
<A class=moz-txt-link-freetext href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" moz-do-not-send="true">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</A>
</PRE></BLOCKQUOTE><BR><PRE class=moz-signature cols="72">-- 
Daniel-Constantin Mierla
<A class=moz-txt-link-freetext href="http://www.asipto.com" moz-do-not-send="true">http://www.asipto.com</A></PRE></DIV></DIV></DIV></BLOCKQUOTE><BR><PRE class=moz-signature cols="72">-- 
Daniel-Constantin Mierla
<A class=moz-txt-link-freetext href="http://www.asipto.com">http://www.asipto.com</A></PRE></DIV></DIV></DIV></BODY></HTML>