#include "client.h"
#include "hash.h"
#include "ircd_alloc.h"
+#include "ircd_features.h"
#include "ircd_log.h"
#include "ircd_osdep.h"
#include "ircd_reply.h"
#include "ircd.h"
#include "list.h"
+#include "msgq.h"
#include "numeric.h"
#include "numnicks.h"
#include "res.h"
#include <string.h>
#include <unistd.h>
-/* *INDENT-OFF* */
-
/*
* Option string. Must be before #ifdef DEBUGMODE.
*/
-char serveropts[] = {
-#if BUFFERPOOL < 1000000
- 'b',
-#if BUFFERPOOL > 99999
- (char)('0' + (BUFFERPOOL/100000)),
-#endif
-#if BUFFERPOOL > 9999
- (char)('0' + (BUFFERPOOL/10000) % 10),
-#endif
- (char)('0' + (BUFFERPOOL/1000) % 10),
-#else
- 'B',
-#if BUFFERPOOL > 99999999
- (char)('0' + (BUFFERPOOL/100000000)),
-#endif
-#if BUFFERPOOL > 9999999
- (char)('0' + (BUFFERPOOL/10000000) % 10),
-#endif
- (char)('0' + (BUFFERPOOL/1000000) % 10),
-#endif
+static char serveropts[256]; /* should be large enough for anything */
+
+const char* debug_serveropts(void)
+{
+ int bp;
+ int i = 0;
+#define AddC(c) serveropts[i++] = (c)
+
+ bp = feature_int(FEAT_BUFFERPOOL);
+ if (bp < 1000000) {
+ AddC('b');
+ if (bp > 99999)
+ AddC((char)('0' + (bp / 100000)));
+ if (bp > 9999)
+ AddC((char)('0' + (bp / 10000) % 10));
+ AddC((char)('0' + (bp / 1000) % 10));
+ } else {
+ AddC('B');
+ if (bp > 99999999)
+ AddC((char)('0' + (bp / 100000000)));
+ if (bp > 9999999)
+ AddC((char)('0' + (bp / 10000000) % 10));
+ AddC((char)('0' + (bp / 1000000) % 10));
+ }
+
#ifdef CHROOTDIR
- 'c',
+ AddC('c');
#endif
#ifdef CMDLINE_CONFIG
- 'C',
-#endif
-#ifdef DO_ID
- 'd',
+ AddC('C');
#endif
#ifdef DEBUGMODE
- 'D',
-#endif
-#ifdef LOCOP_REHASH
- 'e',
-#endif
-#ifdef OPER_REHASH
- 'E',
-#endif
-#ifdef OPER_NO_CHAN_LIMIT
- 'F',
-#endif
-#ifdef OPER_MODE_LCHAN
- 'f',
-#endif
-#ifdef HUB
- 'H',
-#endif
-#if defined(SHOW_INVISIBLE_USERS) || defined(SHOW_ALL_INVISIBLE_USERS)
-#ifdef SHOW_ALL_INVISIBLE_USERS
- 'I',
-#else
- 'i',
-#endif
-#endif
-#ifdef OPER_KILL
-#ifdef LOCAL_KILL_ONLY
- 'k',
-#else
- 'K',
-#endif
-#endif
-#ifdef LEAST_IDLE
- 'L',
-#endif
-#ifdef OPER_WALK_THROUGH_LMODES
- 'l',
-#endif
-#ifdef IDLE_FROM_MSG
- 'M',
-#endif
-#ifdef USEONE
- 'O',
-#endif
-#ifdef NO_OPER_DEOP_LCHAN
- 'o',
-#endif
-#ifdef CRYPT_OPER_PASSWORD
- 'p',
-#endif
-#ifdef CRYPT_LINK_PASSWORD
- 'P',
-#endif
-#ifdef DEBUGMALLOC
-#ifdef MEMLEAKSTATS
- 'Q',
-#else
- 'q',
-#endif
-#endif
-#ifdef RELIABLE_CLOCK
- 'R',
-#endif
-#ifdef LOCOP_RESTART
- 's',
-#endif
-#ifdef OPER_RESTART
- 'S',
-#endif
-#ifdef OPER_REMOTE
- 't',
+ AddC('D');
#endif
+
+ if (feature_bool(FEAT_LOCOP_REHASH))
+ AddC('e');
+
+ if (feature_bool(FEAT_OPER_REHASH))
+ AddC('E');
+
+ if (feature_bool(FEAT_OPER_NO_CHAN_LIMIT))
+ AddC('F');
+
+ if (feature_bool(FEAT_OPER_MODE_LCHAN))
+ AddC('f');
+
+ if (feature_bool(FEAT_HUB))
+ AddC('H');
+
+ if (feature_bool(FEAT_SHOW_ALL_INVISIBLE_USERS))
+ AddC('I');
+ else if (feature_bool(FEAT_SHOW_INVISIBLE_USERS))
+ AddC('i');
+
+ if (feature_bool(FEAT_OPER_KILL)) {
+ if (feature_bool(FEAT_LOCAL_KILL_ONLY))
+ AddC('k');
+ else
+ AddC('K');
+ }
+
+ if (feature_bool(FEAT_OPER_WALK_THROUGH_LMODES))
+ AddC('l');
+
+ if (feature_bool(FEAT_IDLE_FROM_MSG))
+ AddC('M');
+
+ if (feature_bool(FEAT_NO_OPER_DEOP_LCHAN))
+ AddC('o');
+
+ if (feature_bool(FEAT_CRYPT_OPER_PASSWORD))
+ AddC('p');
+
+ if (feature_bool(FEAT_RELIABLE_CLOCK))
+ AddC('R');
+
+ if (feature_bool(FEAT_LOCOP_RESTART))
+ AddC('s');
+
+ if (feature_bool(FEAT_OPER_RESTART))
+ AddC('S');
+
#if defined(USE_POLL) && defined(HAVE_POLL_H)
- 'U',
-#endif
-#ifdef VIRTUAL_HOST
- 'v',
-#endif
-#ifdef BADCHAN
- 'W',
-#ifdef LOCAL_BADCHAN
- 'x',
+ AddC('U');
#endif
-#endif
- '\0'
-};
-/* *INDENT-ON* */
+ if (feature_bool(FEAT_VIRTUAL_HOST))
+ AddC('v');
+
+ serveropts[i] = '\0';
+ return serveropts;
+}
/*
* debug_init
#ifdef DEBUGMODE
if (debuglevel >= 0) {
printf("isatty = %d ttyname = %s\n", isatty(2), ttyname(2));
- log_debug_init(use_tty ? 0 : LOGFILE);
+ log_debug_init(use_tty);
}
#endif
}
*/
void send_usage(struct Client *cptr, char *nick)
{
- os_get_rusage(cptr, CurrentTime - me.since, debug_enumerator);
+ os_get_rusage(cptr, CurrentTime - cli_since(&me), debug_enumerator);
send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":DBUF alloc %d used %d",
DBufAllocCount, DBufUsedCount);
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 */
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 */
com = 0, /* memory used by conf lines */
dbufs_allocated = 0, /* memory used by dbufs */
dbufs_used = 0, /* memory used by dbufs */
+ msg_allocated = 0, /* memory used by struct Msg */
+ msg_used = 0, /* memory used by struct Msg */
+ msgbuf_allocated = 0, /* memory used by struct MsgBuf */
+ msgbuf_used = 0, /* memory used by struct MsgBuf */
rm = 0, /* res memory used */
totcl = 0, totch = 0, totww = 0, tot = 0;
wwm += sizeof(struct Whowas) * NICKNAMEHISTORYLENGTH;
wwm += sizeof(struct Whowas *) * WW_MAX;
- for (acptr = GlobalClientList; acptr; acptr = acptr->next)
+ for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr))
{
+ c++;
if (MyConnect(acptr))
{
- lc++;
- for (link = acptr->confs; link; link = link->next)
+ cn++;
+ for (link = cli_confs(acptr); link; link = link->next)
lcc++;
}
- else
- rc++;
- if (acptr->user)
+ if (cli_user(acptr))
{
us++;
- for (link = acptr->user->invited; link; link = link->next)
+ for (link = cli_user(acptr)->invited; link; link = link->next)
usi++;
- for (member = acptr->user->channel; member; member = member->next_channel)
+ for (member = cli_user(acptr)->channel; member; member = member->next_channel)
++memberships;
- if (acptr->user->away)
+ if (cli_user(acptr)->away)
{
aw++;
- awm += (strlen(acptr->user->away) + 1);
+ awm += (strlen(cli_user(acptr)->away) + 1);
}
}
}
- 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)
{
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));
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,
":DBufs allocated %d(%zu) used %d(%zu)", DBufAllocCount,
dbufs_allocated, DBufUsedCount, dbufs_used);
+ msgq_count_memory(&msg_allocated, &msg_used, &msgbuf_allocated,
+ &msgbuf_used);
+ send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG,
+ ":Msgs allocated %d(%zu) used %d(%zu)", msgCounts.alloc,
+ msg_allocated, msgCounts.used, msg_used);
+ send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG,
+ ":MsgBufs allocated %d(%zu) used %d(%zu)", msgBufCounts.alloc,
+ msgbuf_allocated, msgBufCounts.used, msgbuf_used);
+
rm = cres_mem(cptr);
tot =
- totww + totch + totcl + com + cl * sizeof(struct ConnectionClass) + dbufs_allocated +
- rm;
+ totww + totch + totcl + com + cl * sizeof(struct ConnectionClass) +
+ dbufs_allocated + msg_allocated + msgbuf_allocated + rm;
tot += sizeof(void *) * HASHSIZE * 3;
#if !defined(NDEBUG)
#endif
send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG,
- ":Total: ww %zu ch %zu cl %zu co %zu db %zu", totww, totch,
- totcl, com, dbufs_allocated);
+ ":Total: ww %zu ch %zu cl %zu co %zu db %zu ms %zu mb %zu",
+ totww, totch, totcl, com, dbufs_allocated, msg_allocated,
+ msgbuf_allocated);
}