<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4611.1300" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>I have spent the
last day reviewing the karma code and have found that it needs some cleaning
up. I would like to propose the following changes and get some input from
the more experienced jabberd developers.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>The code in mio.c
regarding karma does not pay attention to most of what you place in the
<io><karma> section of the jabber.xml. Two reasons 1) a
typical cut and paste coding mistake. 2) Then the information is not even used
latter just the karma defaults found in lib.h.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>Here is a diff of
the changes I have made to mio.c so far.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001>532c532<BR>< mio_karma(new,
KARMA_INIT, KARMA_MAX, KARMA_INC, KARMA_DEC, KARMA_PENALTY,
KARMA_RESTORE);<BR>---<BR>> mio_karma(new,
KARMA_INIT, KARMA_DEF_MAX, KARMA_DEF_INC, KARMA_DEF_DEC, KARMA_DEF_PENALTY,
KARMA_DEF_RESTORE);<BR>770,777c770,777<BR><
KARMA_DEF_INIT = j_atoi(xmlnode_get_tag_data(io, "karma/init"),
KARMA_INIT);<BR>< KARMA_DEF_INIT =
j_atoi(xmlnode_get_tag_data(io, "karma/max"),
KARMA_MAX);<BR>< KARMA_DEF_INIT =
j_atoi(xmlnode_get_tag_data(io, "karma/inc"),
KARMA_INC);<BR>< KARMA_DEF_INIT =
j_atoi(xmlnode_get_tag_data(io, "karma/dec"),
KARMA_DEC);<BR>< KARMA_DEF_INIT =
j_atoi(xmlnode_get_tag_data(io, "karma/penalty"),
KARMA_PENALTY);<BR>< KARMA_DEF_INIT =
j_atoi(xmlnode_get_tag_data(io, "karma/restore"),
KARMA_RESTORE);<BR>< KARMA_DEF_RATE_T =
j_atoi(xmlnode_get_attrib(xmlnode_get_tag(io, "rate"), "time"),
5);<BR>< KARMA_DEF_RATE_P =
j_atoi(xmlnode_get_attrib(xmlnode_get_tag(io, "rate"), "points"),
25);<BR>---<BR>> KARMA_DEF_INIT =
j_atoi(xmlnode_get_tag_data(io, "karma/init"),
KARMA_INIT);<BR>>
KARMA_DEF_MAX = j_atoi(xmlnode_get_tag_data(io,
"karma/max"), KARMA_MAX);<BR>>
KARMA_DEF_INC = j_atoi(xmlnode_get_tag_data(io,
"karma/inc"), KARMA_INC);<BR>>
KARMA_DEF_DEC = j_atoi(xmlnode_get_tag_data(io,
"karma/dec"), KARMA_DEC);<BR>> KARMA_DEF_PENALTY =
j_atoi(xmlnode_get_tag_data(io, "karma/penalty"),
KARMA_PENALTY);<BR>> KARMA_DEF_RESTORE =
j_atoi(xmlnode_get_tag_data(io, "karma/restore"),
KARMA_RESTORE);<BR>> KARMA_DEF_RATE_T =
j_atoi(xmlnode_get_attrib(xmlnode_get_tag(io, "rate"), "time"),
5);<BR>> KARMA_DEF_RATE_P =
j_atoi(xmlnode_get_attrib(xmlnode_get_tag(io, "rate"), "points"),
25);<BR>782c782<BR><
register_beat(j_atoi(xmlnode_get_tag_data(io, "heartbeat"), KARMA_HEARTBEAT),
_karma_heartbeat,
NULL);<BR>---<BR>>
register_beat(j_atoi(xmlnode_get_tag_data(io, "karma/heartbeat"),
KARMA_HEARTBEAT), _karma_heartbeat,
NULL);<BR>855c855<BR>< mio_karma(new, KARMA_INIT,
KARMA_MAX, KARMA_INC, KARMA_DEC, KARMA_PENALTY,
KARMA_RESTORE);<BR>---<BR>> mio_karma(new,
KARMA_INIT, KARMA_DEF_MAX, KARMA_DEF_INC, KARMA_DEF_DEC, KARMA_DEF_PENALTY,
KARMA_DEF_RESTORE);</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>I have continued to
leave KARMA_INIT as is fore the time being because this used in some strange way
to indicate it is a new connection. I will spend some more time on
completing that transition.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001>----------------------------------------------</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>The karma_heartbeat
has been adjust for registration, but the default value of KARMA_HEARTBEAT is
used in karma.c and may or may not reflect the true heartbeat setting set in
<io><karma>.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>karma.c
66-68</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>
/* only increment every KARMA_HEARTBEAT seconds */<BR> if( (
k->last_update + KARMA_HEARTBEAT > cur_time ) && k->last_update
!= 0)<BR> return;</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>I propose adding a
KARMA_DEF_HEARTBEAT that is set in mio.c and then used as an extern in
karma.c.</DIV>
<DIV><BR>-----------------------------------------------</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001> </DIV></SPAN></FONT>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>Also client.c and
some others use their own karma settings than those found in <io> and as
state by a comment in the code that they would first like to uses the
<io><karma> setting instead of the defaults found
lib.h.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>What I propose is
adding the externs that point to KARMA_DEF... in client .c
et.al.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>client.c
504-509</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001>
/* XXX note, this isn't quite what i had in mind for
karma<BR>
* since it's not taking the default from <io/> over the
<BR> *
internal defaults... it should take the c2s config
first<BR>
* any values not there should come from <io/> and any
other<BR>
* non-matched values should use the internal defaults
*/<BR>
mio_karma2(m, &k);</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001>----------------------------------------</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>I would apprciate
feedback on the cleanup presented. Who would I send the updates for
inclusion into CVS.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=240032320-03052001></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=240032320-03052001>
<DIV><FONT face=Arial size=2>heg</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>"If at first the idea is not absurd, then there is
no hope for it." - Albert
Einstein</FONT></DIV></DIV></SPAN></FONT></BODY></HTML>