Working over zipstats bug and moving on the new ServerStats struct (without Kb counting, this style is used by code parts from ratbox3)

This commit is contained in:
Valery Yatsko 2008-04-08 18:00:38 +04:00
parent b8730cbf86
commit 4c79bbd350
4 changed files with 24 additions and 62 deletions

View file

@ -111,14 +111,10 @@ struct Server
struct ZipStats
{
unsigned long in;
unsigned long in_wire;
unsigned long out;
unsigned long out_wire;
unsigned long inK;
unsigned long inK_wire;
unsigned long outK;
unsigned long outK_wire;
unsigned long long in;
unsigned long long in_wire;
unsigned long long out;
unsigned long long out_wire;
double in_ratio;
double out_ratio;
};

View file

@ -45,14 +45,10 @@ struct ServerStatistics
unsigned int is_cl; /* number of client connections */
unsigned int is_sv; /* number of server connections */
unsigned int is_ni; /* connection but no idea who it was */
unsigned short is_cbs; /* bytes sent to clients */
unsigned short is_cbr; /* bytes received to clients */
unsigned short is_sbs; /* bytes sent to servers */
unsigned short is_sbr; /* bytes received to servers */
unsigned long is_cks; /* k-bytes sent to clients */
unsigned long is_ckr; /* k-bytes received to clients */
unsigned long is_sks; /* k-bytes sent to servers */
unsigned long is_skr; /* k-bytes received to servers */
unsigned long long int is_cbs; /* bytes sent to clients */
unsigned long long int is_cbr; /* bytes received to clients */
unsigned long long int is_sbs; /* bytes sent to servers */
unsigned long long int is_sbr; /* bytes received to servers */
time_t is_cti; /* time spent connected by clients */
time_t is_sti; /* time spent connected by servers */
unsigned int is_ac; /* connections accepted */

View file

@ -1445,31 +1445,25 @@ stats_ziplinks (struct Client *source_p)
{
rb_dlink_node *ptr;
struct Client *target_p;
struct ZipStats *zipstats;
int sent_data = 0;
char buf[128], buf1[128];
RB_DLINK_FOREACH (ptr, serv_list.head)
{
target_p = ptr->data;
if(IsCapable (target_p, CAP_ZIP))
{
/* we use memcpy(3) and a local copy of the structure to
* work around a register use bug on GCC on the SPARC.
* -jmallett, 04/27/2002
*/
struct ZipStats zipstats;
memcpy (&zipstats, &target_p->localClient->zipstats,
sizeof (struct ZipStats));
snprintf(buf, sizeof buf, "%.2f%%", zipstats.out_ratio);
snprintf(buf1, sizeof buf1, "%.2f%%", zipstats.in_ratio);
zipstats = target_p->localClient->zipstats;
sprintf(buf, "%.2f%%", zipstats->out_ratio);
sprintf(buf1, "%.2f%%", zipstats->in_ratio);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"Z :ZipLinks stats for %s send[%s compression "
"(%lu kB data/%lu kB wire)] recv[%s compression "
"(%lu kB data/%lu kB wire)]",
"(%llu kB data/%llu kB wire)] recv[%s compression "
"(%llu kB data/%llu kB wire)]",
target_p->name,
buf, zipstats.outK, zipstats.outK_wire,
buf1, zipstats.inK, zipstats.inK_wire);
buf, zipstats->out >> 10,
zipstats->out_wire >> 10, buf1,
zipstats->in >> 10, zipstats->in_wire >> 10);
sent_data++;
}
}

View file

@ -2040,19 +2040,7 @@ close_connection(struct Client *client_p)
ServerStats.is_sv++;
ServerStats.is_sbs += client_p->localClient->sendB;
ServerStats.is_sbr += client_p->localClient->receiveB;
ServerStats.is_sks += client_p->localClient->sendK;
ServerStats.is_skr += client_p->localClient->receiveK;
ServerStats.is_sti += rb_current_time() - client_p->localClient->firsttime;
if(ServerStats.is_sbs > 2047)
{
ServerStats.is_sks += (ServerStats.is_sbs >> 10);
ServerStats.is_sbs &= 0x3ff;
}
if(ServerStats.is_sbr > 2047)
{
ServerStats.is_skr += (ServerStats.is_sbr >> 10);
ServerStats.is_sbr &= 0x3ff;
}
/*
* If the connection has been up for a long amount of time, schedule
@ -2078,19 +2066,7 @@ close_connection(struct Client *client_p)
ServerStats.is_cl++;
ServerStats.is_cbs += client_p->localClient->sendB;
ServerStats.is_cbr += client_p->localClient->receiveB;
ServerStats.is_cks += client_p->localClient->sendK;
ServerStats.is_ckr += client_p->localClient->receiveK;
ServerStats.is_cti += rb_current_time() - client_p->localClient->firsttime;
if(ServerStats.is_cbs > 2047)
{
ServerStats.is_cks += (ServerStats.is_cbs >> 10);
ServerStats.is_cbs &= 0x3ff;
}
if(ServerStats.is_cbr > 2047)
{
ServerStats.is_ckr += (ServerStats.is_cbr >> 10);
ServerStats.is_cbr &= 0x3ff;
}
}
else
ServerStats.is_ni++;