From: Kevin L. Mitchell Date: Thu, 14 Dec 2000 16:32:04 +0000 (+0000) Subject: Author: Kev X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=eef0266ff4630479b9fafec826c249564125b948;p=ircu2.10.12-pk.git Author: Kev Log message: This is it! Connection information in struct Client has been pulled out into its own structure, struct Connection. I've also added a couple of fields to struct Connection to enable me to create a more efficient implementation of flush_connections() in the future... Testing: Compiles and runs without any apparent problems. We need to bombard it with clones up the wazoo to verify the integrity of make_client() and free_client(). git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@337 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index e9ed9b2..1577891 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2000-12-14 Kevin L. Mitchell + + * ircd/s_debug.c (count_memory): modify to report for clients and + connections, not local clients and remote clients + + * ircd/list.c: fiddle with the client-fiddling functions to take + into account the divorce of struct Connection from struct Client + + * ircd/ircd.c: define a struct Connection for me, initialize it, + and link it into the right place (ewww, globals!) + + * include/client.h: remove CLIENT_{LOCAL,REMOTE}_SIZE; split + struct Client into struct Client and struct Connection; redefine + local-portion accessor macros to go through struct Client to the + struct Connection; define struct Connection accessor macros + 2000-12-13 Kevin L. Mitchell * ircd/whowas.c: missed a couple of accesses to a struct Client diff --git a/include/client.h b/include/client.h index 3e1d998..fe839f7 100644 --- a/include/client.h +++ b/include/client.h @@ -56,12 +56,6 @@ struct Whowas; struct DNSReply; struct hostent; -/*----------------------------------------------------------------------------- - * Macros - */ -#define CLIENT_LOCAL_SIZE sizeof(struct Client) -#define CLIENT_REMOTE_SIZE offsetof(struct Client, cli_count) - /* * Structures * @@ -70,34 +64,7 @@ struct hostent; * source file, or in the source file itself (when only used in that file). */ -struct Client { - struct Client* cli_next; /* link in GlobalClientList */ - struct Client* cli_prev; /* link in GlobalClientList */ - struct Client* cli_hnext; /* link in hash table bucket or this */ - struct Client* cli_from; /* == self, if Local Client, *NEVER* NULL! */ - struct User* cli_user; /* ...defined, if this is a User */ - struct Server* cli_serv; /* ...defined, if this is a server */ - struct Whowas* cli_whowas; /* Pointer to ww struct to be freed on quit */ - char cli_yxx[4]; /* Numeric Nick: YMM if this is a server, - XX0 if this is a user */ - /* - * XXX - move these to local part for next release - * (lasttime, since) - */ - time_t cli_lasttime; /* last time data read from socket */ - time_t cli_since; /* last time we parsed something, flood control */ - - time_t cli_firsttime; /* time client was created */ - time_t cli_lastnick; /* TimeStamp on nick */ - int cli_marker; /* /who processing marker */ - unsigned int cli_flags; /* client flags */ - unsigned int cli_hopcount; /* number of servers to this 0 = local */ - struct in_addr cli_ip; /* Real ip# NOT defined for remote servers! */ - short cli_status; /* Client type */ - unsigned char cli_local; /* local or remote client */ - char cli_name[HOSTLEN + 1]; /* Unique name of the client, nick or host */ - char cli_username[USERLEN + 1]; /* username here now for auth stuff */ - char cli_info[REALLEN + 1]; /* Free form additional client information */ +struct Connection { /* * The following fields are allocated only for local clients * (directly connected to *this* server with a socket. @@ -105,44 +72,82 @@ struct Client { * to which the allocation is tied to! *Never* refer to * these fields, if (from != self). */ - unsigned int cli_count; /* Amount of data in buffer, DON'T PUT - variables ABOVE this one! */ - int cli_fd; /* >= 0, for local clients */ - int cli_error; /* last socket level error for client */ - unsigned int cli_snomask; /* mask for server messages */ - time_t cli_nextnick; /* Next time a nick change is allowed */ - time_t cli_nexttarget; /* Next time a target change is allowed */ - unsigned int cli_cookie; /* Random number the user must PONG */ - struct MsgQ cli_sendQ; /* Outgoing message queue--if socket full */ - struct DBuf cli_recvQ; /* Hold for data incoming yet to be parsed */ - unsigned int cli_sendM; /* Statistics: protocol messages send */ - unsigned int cli_sendK; /* Statistics: total k-bytes send */ - unsigned int cli_receiveM; /* Statistics: protocol messages received */ - unsigned int cli_receiveK; /* Statistics: total k-bytes received */ - unsigned short cli_sendB; /* counters to count upto 1-k lots of bytes */ - unsigned short cli_receiveB; /* sent and received. */ - struct Listener* cli_listener; /* listening client which we accepted from */ - struct SLink* cli_confs; /* Configuration record associated */ - HandlerType cli_handler; /* message index into command table for parsing */ - struct DNSReply* cli_dns_reply; /* DNS reply used during client registration */ - struct ListingArgs* cli_listing; - unsigned int cli_max_sendq; /* cached max send queue for client */ - unsigned int cli_ping_freq; /* cached ping freq from client conf class */ - unsigned short cli_lastsq; /* # 2k blocks when sendqueued called last */ - unsigned short cli_port; /* and the remote port# too :-) */ - unsigned char cli_targets[MAXTARGETS]; /* Hash values of current targets */ - char cli_sock_ip[SOCKIPLEN + 1]; /* this is the ip address as a string */ - char cli_sockhost[HOSTLEN + 1]; /* This is the host name from the socket and - after which the connection was accepted. */ - char cli_passwd[PASSWDLEN + 1]; - char cli_buffer[BUFSIZE]; /* Incoming message buffer; or the error that + struct Connection* con_next; /* Next connection with queued data */ + struct Connection** con_prev_p; /* What points to us */ + struct Client* con_client; /* Client associated with connection */ + unsigned int con_count; /* Amount of data in buffer */ + int con_fd; /* >= 0, for local clients */ + int con_error; /* last socket level error for client */ + unsigned int con_snomask; /* mask for server messages */ + time_t con_nextnick; /* Next time a nick change is allowed */ + time_t con_nexttarget;/* Next time a target change is allowed */ + unsigned int con_cookie; /* Random number the user must PONG */ + struct MsgQ con_sendQ; /* Outgoing message queue--if socket full */ + struct DBuf con_recvQ; /* Hold for data incoming yet to be parsed */ + unsigned int con_sendM; /* Statistics: protocol messages send */ + unsigned int con_sendK; /* Statistics: total k-bytes send */ + unsigned int con_receiveM;/* Statistics: protocol messages received */ + unsigned int con_receiveK; /* Statistics: total k-bytes received */ + unsigned short con_sendB; /* counters to count upto 1-k lots of bytes */ + unsigned short con_receiveB; /* sent and received. */ + struct Listener* con_listener; /* listening client which we accepted + from */ + struct SLink* con_confs; /* Configuration record associated */ + HandlerType con_handler; /* message index into command table + for parsing */ + struct DNSReply* con_dns_reply; /* DNS reply used during client + registration */ + struct ListingArgs* con_listing; + unsigned int con_max_sendq; /* cached max send queue for client */ + unsigned int con_ping_freq; /* cached ping freq from client conf + class */ + unsigned short con_lastsq; /* # 2k blocks when sendqueued called last */ + unsigned short con_port; /* and the remote port# too :-) */ + unsigned char con_targets[MAXTARGETS]; /* Hash values of current + targets */ + char con_sock_ip[SOCKIPLEN + 1]; /* this is the ip address as a string */ + char con_sockhost[HOSTLEN + 1]; /* This is the host name from the socket and + after which the connection was accepted. */ + char con_passwd[PASSWDLEN + 1]; + char con_buffer[BUFSIZE]; /* Incoming message buffer; or the error that caused this clients socket to be `dead' */ }; +struct Client { + struct Client* cli_next; /* link in GlobalClientList */ + struct Client* cli_prev; /* link in GlobalClientList */ + struct Client* cli_hnext; /* link in hash table bucket or this */ + struct Connection* cli_connect; /* Connection structure associated with us */ + struct User* cli_user; /* ...defined, if this is a User */ + struct Server* cli_serv; /* ...defined, if this is a server */ + struct Whowas* cli_whowas; /* Pointer to ww struct to be freed on quit */ + char cli_yxx[4]; /* Numeric Nick: YMM if this is a server, + XX0 if this is a user */ + /* + * XXX - move these to local part for next release + * (lasttime, since) + */ + time_t cli_lasttime; /* last time data read from socket */ + time_t cli_since; /* last time we parsed something, flood control */ + + time_t cli_firsttime; /* time client was created */ + time_t cli_lastnick; /* TimeStamp on nick */ + int cli_marker; /* /who processing marker */ + unsigned int cli_flags; /* client flags */ + unsigned int cli_hopcount; /* number of servers to this 0 = local */ + struct in_addr cli_ip; /* Real ip# NOT defined for remote servers! */ + short cli_status; /* Client type */ + unsigned char cli_local; /* local or remote client */ + char cli_name[HOSTLEN + 1]; /* Unique name of the client, nick or host */ + char cli_username[USERLEN + 1]; /* username here now for auth stuff */ + char cli_info[REALLEN + 1]; /* Free form additional client information */ +}; + #define cli_next(cli) ((cli)->cli_next) #define cli_prev(cli) ((cli)->cli_prev) #define cli_hnext(cli) ((cli)->cli_hnext) -#define cli_from(cli) ((cli)->cli_from) +#define cli_connect(cli) ((cli)->cli_connect) +#define cli_from(cli) ((cli)->cli_connect->con_client) #define cli_user(cli) ((cli)->cli_user) #define cli_serv(cli) ((cli)->cli_serv) #define cli_whowas(cli) ((cli)->cli_whowas) @@ -161,35 +166,68 @@ struct Client { #define cli_username(cli) ((cli)->cli_username) #define cli_info(cli) ((cli)->cli_info) -#define cli_count(cli) ((cli)->cli_count) -#define cli_fd(cli) ((cli)->cli_fd) -#define cli_error(cli) ((cli)->cli_error) -#define cli_snomask(cli) ((cli)->cli_snomask) -#define cli_nextnick(cli) ((cli)->cli_nextnick) -#define cli_nexttarget(cli) ((cli)->cli_nexttarget) -#define cli_cookie(cli) ((cli)->cli_cookie) -#define cli_sendQ(cli) ((cli)->cli_sendQ) -#define cli_recvQ(cli) ((cli)->cli_recvQ) -#define cli_sendM(cli) ((cli)->cli_sendM) -#define cli_sendK(cli) ((cli)->cli_sendK) -#define cli_receiveM(cli) ((cli)->cli_receiveM) -#define cli_receiveK(cli) ((cli)->cli_receiveK) -#define cli_sendB(cli) ((cli)->cli_sendB) -#define cli_receiveB(cli) ((cli)->cli_receiveB) -#define cli_listener(cli) ((cli)->cli_listener) -#define cli_confs(cli) ((cli)->cli_confs) -#define cli_handler(cli) ((cli)->cli_handler) -#define cli_dns_reply(cli) ((cli)->cli_dns_reply) -#define cli_listing(cli) ((cli)->cli_listing) -#define cli_max_sendq(cli) ((cli)->cli_max_sendq) -#define cli_ping_freq(cli) ((cli)->cli_ping_freq) -#define cli_lastsq(cli) ((cli)->cli_lastsq) -#define cli_port(cli) ((cli)->cli_port) -#define cli_targets(cli) ((cli)->cli_targets) -#define cli_sock_ip(cli) ((cli)->cli_sock_ip) -#define cli_sockhost(cli) ((cli)->cli_sockhost) -#define cli_passwd(cli) ((cli)->cli_passwd) -#define cli_buffer(cli) ((cli)->cli_buffer) +#define cli_count(cli) ((cli)->cli_connect->con_count) +#define cli_fd(cli) ((cli)->cli_connect->con_fd) +#define cli_error(cli) ((cli)->cli_connect->con_error) +#define cli_snomask(cli) ((cli)->cli_connect->con_snomask) +#define cli_nextnick(cli) ((cli)->cli_connect->con_nextnick) +#define cli_nexttarget(cli) ((cli)->cli_connect->con_nexttarget) +#define cli_cookie(cli) ((cli)->cli_connect->con_cookie) +#define cli_sendQ(cli) ((cli)->cli_connect->con_sendQ) +#define cli_recvQ(cli) ((cli)->cli_connect->con_recvQ) +#define cli_sendM(cli) ((cli)->cli_connect->con_sendM) +#define cli_sendK(cli) ((cli)->cli_connect->con_sendK) +#define cli_receiveM(cli) ((cli)->cli_connect->con_receiveM) +#define cli_receiveK(cli) ((cli)->cli_connect->con_receiveK) +#define cli_sendB(cli) ((cli)->cli_connect->con_sendB) +#define cli_receiveB(cli) ((cli)->cli_connect->con_receiveB) +#define cli_listener(cli) ((cli)->cli_connect->con_listener) +#define cli_confs(cli) ((cli)->cli_connect->con_confs) +#define cli_handler(cli) ((cli)->cli_connect->con_handler) +#define cli_dns_reply(cli) ((cli)->cli_connect->con_dns_reply) +#define cli_listing(cli) ((cli)->cli_connect->con_listing) +#define cli_max_sendq(cli) ((cli)->cli_connect->con_max_sendq) +#define cli_ping_freq(cli) ((cli)->cli_connect->con_ping_freq) +#define cli_lastsq(cli) ((cli)->cli_connect->con_lastsq) +#define cli_port(cli) ((cli)->cli_connect->con_port) +#define cli_targets(cli) ((cli)->cli_connect->con_targets) +#define cli_sock_ip(cli) ((cli)->cli_connect->con_sock_ip) +#define cli_sockhost(cli) ((cli)->cli_connect->con_sockhost) +#define cli_passwd(cli) ((cli)->cli_connect->con_passwd) +#define cli_buffer(cli) ((cli)->cli_connect->con_buffer) + +#define con_next(con) ((con)->con_next) +#define con_prev_p(con) ((con)->con_prev_p) +#define con_client(con) ((con)->con_client) +#define con_count(con) ((con)->con_count) +#define con_fd(con) ((con)->con_fd) +#define con_error(con) ((con)->con_error) +#define con_snomask(con) ((con)->con_snomask) +#define con_nextnick(con) ((con)->con_nextnick) +#define con_nexttarget(con) ((con)->con_nexttarget) +#define con_cookie(con) ((con)->con_cookie) +#define con_sendQ(con) ((con)->con_sendQ) +#define con_recvQ(con) ((con)->con_recvQ) +#define con_sendM(con) ((con)->con_sendM) +#define con_sendK(con) ((con)->con_sendK) +#define con_receiveM(con) ((con)->con_receiveM) +#define con_receiveK(con) ((con)->con_receiveK) +#define con_sendB(con) ((con)->con_sendB) +#define con_receiveB(con) ((con)->con_receiveB) +#define con_listener(con) ((con)->con_listener) +#define con_confs(con) ((con)->con_confs) +#define con_handler(con) ((con)->con_handler) +#define con_dns_reply(con) ((con)->con_dns_reply) +#define con_listing(con) ((con)->con_listing) +#define con_max_sendq(con) ((con)->con_max_sendq) +#define con_ping_freq(con) ((con)->con_ping_freq) +#define con_lastsq(con) ((con)->con_lastsq) +#define con_port(con) ((con)->con_port) +#define con_targets(con) ((con)->con_targets) +#define con_sock_ip(con) ((con)->con_sock_ip) +#define con_sockhost(con) ((con)->con_sockhost) +#define con_passwd(con) ((con)->con_passwd) +#define con_buffer(con) ((con)->con_buffer) #define STAT_CONNECTING 0x001 /* connecting to another server */ #define STAT_HANDSHAKE 0x002 /* pass - server sent */ diff --git a/ircd/ircd.c b/ircd/ircd.c index 65a445d..fc941da 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -83,6 +83,7 @@ enum { * Global data (YUCK!) *--------------------------------------------------------------------------*/ struct Client me; // That's me +struct Connection me_con; // That's me too struct Client *GlobalClientList = &me; // Pointer to beginning of Client list time_t TSoffset = 0; // Offset of timestamps to system clock int GlobalRehashFlag = 0; // do a rehash if set @@ -612,6 +613,8 @@ int main(int argc, char **argv) { umask(077); /* better safe than sorry --SRB */ memset(&me, 0, sizeof(me)); + memset(&me_con, 0, sizeof(me_con)); + cli_connect(&me) = &me_con; cli_fd(&me) = -1; parse_command_line(argc, argv); diff --git a/ircd/list.c b/ircd/list.c index bf2ac5c..cfeb338 100644 --- a/ircd/list.c +++ b/ircd/list.c @@ -48,14 +48,14 @@ #ifdef DEBUGMODE static struct liststats { int inuse; -} cloc, crem, users, servs, links; +} clients, connections, users, servs, links; #endif -static unsigned int localClientAllocCount; -static struct Client* localClientFreeList; +static unsigned int clientAllocCount; +static struct Client* clientFreeList; -static unsigned int remoteClientAllocCount; -static struct Client* remoteClientFreeList; +static unsigned int connectionAllocCount; +static struct Connection* connectionFreeList; static unsigned int slinkAllocCount; static struct SLink* slinkFreeList; @@ -63,26 +63,99 @@ static struct SLink* slinkFreeList; void init_list(void) { struct Client* cptr; + struct Connection* con; int i; /* - * pre-allocate MAXCONNECTIONS local clients + * pre-allocate MAXCONNECTIONS clients and connections */ for (i = 0; i < MAXCONNECTIONS; ++i) { - cptr = (struct Client*) MyMalloc(CLIENT_LOCAL_SIZE); - cli_next(cptr) = localClientFreeList; - localClientFreeList = cptr; - ++localClientAllocCount; + cptr = (struct Client*) MyMalloc(sizeof(struct Client)); + cli_next(cptr) = clientFreeList; + clientFreeList = cptr; + ++clientAllocCount; + + con = (struct Connection*) MyMalloc(sizeof(struct Connection)); + con_next(con) = connectionFreeList; + connectionFreeList = con; + ++connectionAllocCount; } #ifdef DEBUGMODE - memset(&cloc, 0, sizeof(cloc)); - memset(&crem, 0, sizeof(crem)); + memset(&clients, 0, sizeof(clients)); + memset(&connections, 0, sizeof(connections)); memset(&users, 0, sizeof(users)); memset(&servs, 0, sizeof(servs)); memset(&links, 0, sizeof(links)); #endif } +static struct Client* alloc_client(void) +{ + struct Client* cptr = clientFreeList; + + if (!cptr) { + cptr = (struct Client*) MyMalloc(sizeof(struct Client)); + ++clientAllocCount; + } else + clientFreeList = cli_next(cptr); + +#ifdef DEBUGMODE + clients.inuse++; +#endif + + memset(cptr, 0, sizeof(struct Client)); + + return cptr; +} + +static void dealloc_client(struct Client* cptr) +{ +#ifdef DEBUGMODE + --clients.inuse; +#endif + + cli_next(cptr) = clientFreeList; + clientFreeList = cptr; +} + +static struct Connection* alloc_connection(void) +{ + struct Connection* con = connectionFreeList; + + if (!con) { + con = (struct Connection*) MyMalloc(sizeof(struct Connection)); + ++connectionAllocCount; + } else + connectionFreeList = con_next(con); + +#ifdef DEBUGMODE + connections.inuse++; +#endif + + memset(con, 0, sizeof(struct Connection)); + + return con; +} + +static void dealloc_connection(struct Connection* con) +{ + if (con_dns_reply(con)) + --(con_dns_reply(con)->ref_count); + if (-1 < con_fd(con)) + close(con_fd(con)); + MsgQClear(&(con_sendQ(con))); + DBufClear(&(con_recvQ(con))); + if (con_listener(con)) + release_listener(con_listener(con)); + +#ifdef DEBUGMODE + --connections.inuse; +#endif + + con_next(con) = connectionFreeList; + connectionFreeList = con; +} + /* * Create a new struct Client structure and set it to initial state. * @@ -95,64 +168,36 @@ void init_list(void) struct Client* make_client(struct Client *from, int status) { struct Client* cptr = 0; - /* - * Check freelists first to see if we can grab a client without - * having to call malloc. - */ - if (from) { - /* - * remote client - */ - if ((cptr = remoteClientFreeList)) - remoteClientFreeList = cli_next(cptr); - else { - cptr = (struct Client*) MyMalloc(CLIENT_REMOTE_SIZE); - ++remoteClientAllocCount; - } - assert(0 != cptr); - /* - * NOTE: Do not remove this, a lot of code depends on the entire - * structure being zeroed out - */ - memset(cptr, 0, CLIENT_REMOTE_SIZE); /* All variables are 0 by default */ - cli_from(cptr) = from; - } - else { - /* - * local client - */ - if ((cptr = localClientFreeList)) - localClientFreeList = cli_next(cptr); - else { - cptr = (struct Client*) MyMalloc(CLIENT_LOCAL_SIZE); - ++localClientAllocCount; - } - assert(0 != cptr); - /* - * NOTE: Do not remove this, a lot of code depends on the entire - * structure being zeroed out - */ - memset(cptr, 0, CLIENT_LOCAL_SIZE); /* All variables are 0 by default */ - cli_fd(cptr) = -1; - cli_local(cptr) = 1; + struct Connection* con = 0; + + cptr = alloc_client(); + + assert(0 != cptr); + + if (!from) { /* local client, allocate a struct Connection */ + con = alloc_connection(); + + assert(0 != con); + + con_fd(con) = -1; /* initialize struct Connection */ + con_nextnick(con) = CurrentTime - NICK_DELAY; + con_nexttarget(con) = CurrentTime - (TARGET_DELAY * (STARTTARGETS - 1)); + con_handler(con) = UNREGISTERED_HANDLER; + con_client(con) = cptr; + + cli_local(cptr) = 1; /* Set certain fields of the struct Client */ cli_since(cptr) = cli_lasttime(cptr) = cli_firsttime(cptr) = CurrentTime; cli_lastnick(cptr) = TStime(); - cli_nextnick(cptr) = CurrentTime - NICK_DELAY; - cli_nexttarget(cptr) = CurrentTime - (TARGET_DELAY * (STARTTARGETS - 1)); - cli_handler(cptr) = UNREGISTERED_HANDLER; - cli_from(cptr) = cptr; /* 'from' of local client is self! */ - } + } else + con = cli_connect(from); /* use 'from's connection */ + + assert(0 != con); + + cli_connect(cptr) = con; /* set the connection and other fields */ cli_status(cptr) = status; cli_hnext(cptr) = cptr; strcpy(cli_username(cptr), "unknown"); -#ifdef DEBUGMODE - if (from) - crem.inuse++; - else - cloc.inuse++; -#endif - return cptr; } @@ -165,33 +210,9 @@ void free_client(struct Client* cptr) */ assert(cli_hnext(cptr) == cptr); -#ifdef DEBUGMODE - if (cli_local(cptr)) - --cloc.inuse; - else - --crem.inuse; -#endif - - if (cli_local(cptr)) { - /* - * make sure we have cleaned up local resources - */ - if (cli_dns_reply(cptr)) - --(cli_dns_reply(cptr))->ref_count; - if (-1 < cli_fd(cptr)) { - close(cli_fd(cptr)); - } - MsgQClear(&(cli_sendQ(cptr))); - DBufClear(&(cli_recvQ(cptr))); - if (cli_listener(cptr)) - release_listener(cli_listener(cptr)); - cli_next(cptr) = localClientFreeList; - localClientFreeList = cptr; - } - else { - cli_next(cptr) = remoteClientFreeList; - remoteClientFreeList = cptr; - } + if (cli_from(cptr) == cptr) /* in other words, we're local */ + dealloc_connection(cli_connect(cptr)); /* deallocate the connection... */ + dealloc_client(cptr); /* deallocate the client */ } struct Server *make_server(struct Client *cptr) @@ -349,13 +370,15 @@ void send_listinfo(struct Client *cptr, char *name) { int inuse = 0, mem = 0, tmp = 0; - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Local: inuse: %d(%d)", - inuse += cloc.inuse, tmp = cloc.inuse * CLIENT_LOCAL_SIZE); + send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Clients: inuse: %d(%d)", + clients.inuse, tmp = clients.inuse * sizeof(struct Client)); mem += tmp; - send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Remote: inuse: %d(%d)", - crem.inuse, tmp = crem.inuse * CLIENT_REMOTE_SIZE); + inuse += clients.inuse; + send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, "Connections: inuse: %d(%d)", + connections.inuse, + tmp = connections.inuse * sizeof(struct Connection)); mem += tmp; - inuse += crem.inuse; + inuse += connections.inuse; send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Users: inuse: %d(%d)", users.inuse, tmp = users.inuse * sizeof(struct User)); mem += tmp; diff --git a/ircd/s_debug.c b/ircd/s_debug.c index 6bb79a6..f1c7afd 100644 --- a/ircd/s_debug.c +++ b/ircd/s_debug.c @@ -249,10 +249,10 @@ void count_memory(struct Client *cptr, char *nick) const struct ConnectionClass* cltmp; struct Membership* member; - int lc = 0, /* local clients */ + int c = 0, /* clients */ + cn = 0, /* connections */ ch = 0, /* channels */ lcc = 0, /* local client conf links */ - rc = 0, /* remote clients */ us = 0, /* user structs */ chi = 0, /* channel invites */ chb = 0, /* channel bans */ @@ -267,8 +267,8 @@ void count_memory(struct Client *cptr, char *nick) size_t chm = 0, /* memory used by channels */ chbm = 0, /* memory used by channel bans */ - lcm = 0, /* memory used by local clients */ - rcm = 0, /* memory used by remote clients */ + cm = 0, /* memory used by clients */ + cnm = 0, /* memory used by connections */ awm = 0, /* memory used by aways */ wwam = 0, /* whowas away memory used */ wwm = 0, /* whowas array memory used */ @@ -288,14 +288,13 @@ void count_memory(struct Client *cptr, char *nick) for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr)) { + c++; if (MyConnect(acptr)) { - lc++; + cn++; for (link = cli_confs(acptr); link; link = link->next) lcc++; } - else - rc++; if (cli_user(acptr)) { us++; @@ -310,8 +309,8 @@ void count_memory(struct Client *cptr, char *nick) } } } - lcm = lc * CLIENT_LOCAL_SIZE; - rcm = rc * CLIENT_REMOTE_SIZE; + cm = c * sizeof(struct Client); + cnm = cn * sizeof(struct Connection); for (chptr = GlobalChannelList; chptr; chptr = chptr->next) { @@ -346,7 +345,7 @@ void count_memory(struct Client *cptr, char *nick) cl++; send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, - ":Client Local %d(%zu) Remote %d(%zu)", lc, lcm, rc, rcm); + ":Clients %d(%zu) Connections %d(%zu)", c, cm, cn, cnm); send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Users %d(%zu) Invites %d(%zu)", us, us * sizeof(struct User), usi, usi * sizeof(struct SLink)); @@ -356,7 +355,7 @@ void count_memory(struct Client *cptr, char *nick) send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Attached confs %d(%zu)", lcc, lcc * sizeof(struct SLink)); - totcl = lcm + rcm + us * sizeof(struct User) + memberships * sizeof(struct Membership) + awm; + totcl = cm + cnm + us * sizeof(struct User) + memberships * sizeof(struct Membership) + awm; totcl += lcc * sizeof(struct SLink) + usi * sizeof(struct SLink); send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Conflines %d(%zu)", co,