mirror of
https://github.com/osmarks/ngircd.git
synced 2024-12-13 10:20:28 +00:00
Enable the daemon to dump its internal state in debug-mode.
This patch allows ngIRCd to dump its internal state (connected clients, actual configuration) when compiled with --enable-debug. The daemon catches two more signals: - SIGUSR1: toggle debug mode (on/off), - SIGUSR2: dump internal state to console/syslog.
This commit is contained in:
parent
755f54b150
commit
355828e64f
@ -1274,4 +1274,26 @@ Destroy_UserOrService(CLIENT *Client, const char *Txt, const char *FwdMsg, bool
|
||||
} /* Destroy_UserOrService */
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
GLOBAL void
|
||||
Client_DebugDump(void)
|
||||
{
|
||||
CLIENT *c;
|
||||
|
||||
Log(LOG_DEBUG, "Client status:");
|
||||
c = My_Clients;
|
||||
while (c) {
|
||||
Log(LOG_DEBUG,
|
||||
" - %s, type=%d, host=%s, user=%s, conn=%d, start=%ld, flags=%s",
|
||||
Client_ID(c), Client_Type(c), Client_Hostname(c),
|
||||
Client_User(c), Client_Conn(c), Client_StartTime(c),
|
||||
Client_Flags(c));
|
||||
c = (CLIENT *)c->next;
|
||||
}
|
||||
} /* Client_DumpClients */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* -eof- */
|
||||
|
@ -157,6 +157,12 @@ GLOBAL void Client_RegisterWhowas PARAMS(( CLIENT *Client ));
|
||||
|
||||
GLOBAL const char *Client_TypeText PARAMS((CLIENT *Client));
|
||||
|
||||
#ifdef DEBUG
|
||||
GLOBAL void Client_DebugDump PARAMS((void));
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* -eof- */
|
||||
|
@ -1524,6 +1524,29 @@ va_dcl
|
||||
} /* Config_Error */
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
GLOBAL void
|
||||
Conf_DebugDump(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
Log(LOG_DEBUG, "Configured servers:");
|
||||
for (i = 0; i < MAX_SERVERS; i++) {
|
||||
if (! Conf_Server[i].name[0])
|
||||
continue;
|
||||
Log(LOG_DEBUG,
|
||||
" - %s: %s:%d, last=%ld, group=%d, flags=%d, conn=%d",
|
||||
Conf_Server[i].name, Conf_Server[i].host,
|
||||
Conf_Server[i].port, Conf_Server[i].lasttry,
|
||||
Conf_Server[i].group, Conf_Server[i].flags,
|
||||
Conf_Server[i].conn_id);
|
||||
}
|
||||
} /* Conf_DebugDump */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
Init_Server_Struct( CONF_SERVER *Server )
|
||||
{
|
||||
|
@ -191,6 +191,10 @@ GLOBAL bool Conf_IsService PARAMS((int ConfServer, const char *Nick));
|
||||
/* Password required by WEBIRC command */
|
||||
GLOBAL char Conf_WebircPwd[CLIENT_PASS_LEN];
|
||||
|
||||
#ifdef DEBUG
|
||||
GLOBAL void Conf_DebugDump PARAMS((void));
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -69,6 +69,7 @@ static void Setup_FDStreams PARAMS(( int fd ));
|
||||
|
||||
static bool NGIRCd_Init PARAMS(( bool ));
|
||||
|
||||
|
||||
/**
|
||||
* The main() function of ngIRCd.
|
||||
* Here all starts: this function is called by the operating system loader,
|
||||
@ -723,4 +724,5 @@ NGIRCd_Init( bool NGIRCd_NoDaemon )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* -eof- */
|
||||
|
@ -36,6 +36,22 @@
|
||||
|
||||
static int signalpipe[2];
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static void
|
||||
Dump_State(void)
|
||||
{
|
||||
Log(LOG_DEBUG, "--- Internal server state: ---");
|
||||
Log(LOG_DEBUG, "time()=%ld", time(NULL));
|
||||
Conf_DebugDump();
|
||||
Client_DebugDump();
|
||||
Log(LOG_DEBUG, "--- End of state dump ---");
|
||||
} /* Dump_State */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void Signal_Block(int sig)
|
||||
{
|
||||
#ifdef HAVE_SIGPROCMASK
|
||||
@ -140,6 +156,30 @@ static void Signal_Handler(int Signal)
|
||||
while (waitpid( -1, NULL, WNOHANG) > 0)
|
||||
;
|
||||
return;
|
||||
#ifdef DEBUG
|
||||
case SIGUSR1:
|
||||
if (! NGIRCd_Debug) {
|
||||
Log(LOG_INFO|LOG_snotice,
|
||||
"Got SIGUSR1, debug mode activated.");
|
||||
#ifdef SNIFFER
|
||||
strcpy(NGIRCd_DebugLevel, "2");
|
||||
NGIRCd_Debug = true;
|
||||
NGIRCd_Sniffer = true;
|
||||
#else
|
||||
strcpy(NGIRCd_DebugLevel, "1");
|
||||
NGIRCd_Debug = true;
|
||||
#endif /* SNIFFER */
|
||||
} else {
|
||||
Log(LOG_INFO|LOG_snotice,
|
||||
"Got SIGUSR1, debug mode deactivated.");
|
||||
strcpy(NGIRCd_DebugLevel, "");
|
||||
NGIRCd_Debug = false;
|
||||
#ifdef SNIFFER
|
||||
NGIRCd_Sniffer = false;
|
||||
#endif /* SNIFFER */
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -169,6 +209,10 @@ static void Signal_Handler_BH(int Signal)
|
||||
NGIRCd_Rehash();
|
||||
break;
|
||||
#ifdef DEBUG
|
||||
case SIGUSR2:
|
||||
if (NGIRCd_Debug)
|
||||
Dump_State();
|
||||
break;
|
||||
default:
|
||||
Log(LOG_DEBUG, "Got signal %d! Ignored.", Signal);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user