struct ConnectionClass *tmp;
tmp = (struct ConnectionClass*) MyMalloc(sizeof(struct ConnectionClass));
+ tmp->ref_count = 1;
assert(0 != tmp);
++connClassAllocCount;
return tmp;
void free_class(struct ConnectionClass* p)
{
- if (p) {
+ if (p)
+ {
assert(0 == p->valid);
if (p->cc_name)
- MyFree(p->cc_name);
+ MyFree(p->cc_name);
MyFree(p);
--connClassAllocCount;
}
for (prev = cl = connClassList; cl; cl = prev->next) {
Debug((DEBUG_DEBUG, "Class %s : CF: %d PF: %d ML: %d LI: %d SQ: %d",
- ConClass(cl), ConFreq(cl), PingFreq(cl), MaxLinks(cl), Links(cl), MaxSendq(cl)));
+ ConClass(cl), ConFreq(cl), PingFreq(cl), MaxLinks(cl),
+ Links(cl), MaxSendq(cl)));
/*
* unlink marked classes, delete unreferenced ones
*/
if (cl->valid)
prev = cl;
- else {
+ else
+ {
prev->next = cl->next;
- if (0 == cl->ref_count)
+ if (0 == --cl->ref_count)
free_class(cl);
}
}
if (acptr && !IsMe(acptr) && (cli_confs(acptr)))
for (tmp = cli_confs(acptr); tmp; tmp = tmp->next)
{
- if (tmp->value.aconf && !(cl = tmp->value.aconf->conn_class))
+ if (tmp->value.aconf && (cl = tmp->value.aconf->conn_class))
return ConClass(cl);
}
return "(null-class)";
}
-unsigned int get_client_ping(struct Client *acptr)
-{
- unsigned int ping = 0;
- unsigned int ping2;
- struct ConfItem *aconf;
- struct SLink *link;
-
- link = cli_confs(acptr);
-
- if (link) {
- while (link) {
- aconf = link->value.aconf;
- if (aconf->status & (CONF_CLIENT | CONF_SERVER)) {
- ping2 = get_conf_ping(aconf);
- if ((ping2 != BAD_PING) && ((ping > ping2) || !ping))
- ping = ping2;
- }
- link = link->next;
- }
- }
- else {
- ping = feature_int(FEAT_PINGFREQUENCY);
- Debug((DEBUG_DEBUG, "No Attached Confs for: %s", cli_name(acptr)));
- }
- if (ping <= 0)
- ping = feature_int(FEAT_PINGFREQUENCY);
- Debug((DEBUG_DEBUG, "Client %s Ping %d", cli_name(acptr), ping));
- return (ping);
-}
-
unsigned int get_con_freq(struct ConnectionClass * clptr)
{
if (clptr)
t->next = p;
}
else
+ {
+ if (ConClass(t) != NULL)
+ MyFree(ConClass(t));
p = t;
+ }
Debug((DEBUG_DEBUG, "Add Class %s: cf: %u pf: %u ml: %u sq: %d",
name, confreq, ping, maxli, sendq));
ConClass(p) = name;
}
void
-report_classes(struct Client *sptr)
+report_classes(struct Client *sptr, struct StatDesc *sd, int stat,
+ char *param)
{
struct ConnectionClass *cltmp;
void class_send_meminfo(struct Client* cptr)
{
send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Classes: inuse: %d(%d)",
- connClassAllocCount, connClassAllocCount * sizeof(struct ConnectionClass));
+ connClassAllocCount,
+ connClassAllocCount * sizeof(struct ConnectionClass));
}