Commit Diff


commit - 755f54b1501334d827b5c30c03b4551ebb5cbe0d
commit + 355828e64f6fa07eb96bc6b27eef964b529d8778
blob - f73a2d1ef0b46242bbeed67a8f0a64608b46ab34
blob + d53dc969cd47269c65f73314b4b8b55d95de66d2
--- src/ngircd/client.c
+++ src/ngircd/client.c
@@ -1272,6 +1272,28 @@ Destroy_UserOrService(CLIENT *Client, const char *Txt,
 	/* Register client in My_Whowas structure */
 	Client_RegisterWhowas(Client);
 } /* 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- */
blob - 98a0d1a4e327011fa571154f9657c2143657a9f2
blob + 42036c4e79f89c164b6f2dd13b499543bcd1a3ab
--- src/ngircd/client.h
+++ src/ngircd/client.h
@@ -157,6 +157,12 @@ GLOBAL void Client_RegisterWhowas PARAMS(( CLIENT *Cli
 
 GLOBAL const char *Client_TypeText PARAMS((CLIENT *Client));
 
+#ifdef DEBUG
+GLOBAL void Client_DebugDump PARAMS((void));
 #endif
 
+
+#endif
+
+
 /* -eof- */
blob - a70973e78cf8b47d33eeac5cb54a27f8388e4fef
blob + 5619a6c78e9f6c0840300bb3daba6c67a8ffd404
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
@@ -1522,8 +1522,31 @@ va_dcl
 	if (Use_Log) Log( Level, "%s", msg );
 	else puts( msg );
 } /* 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 )
 {
blob - e7b84d2e16facd41000109629c2939b56c6a9940
blob + 5cf5f6b11d9bfcfb19ad5d8925c8cdcc3844a52e
--- src/ngircd/conf.h
+++ src/ngircd/conf.h
@@ -191,7 +191,11 @@ GLOBAL bool Conf_IsService PARAMS((int ConfServer, con
 /* Password required by WEBIRC command */
 GLOBAL char Conf_WebircPwd[CLIENT_PASS_LEN];
 
+#ifdef DEBUG
+GLOBAL void Conf_DebugDump PARAMS((void));
+#endif
 
+
 #endif
 
 
blob - 2fd60ef8713295d08bd9276110539b65e97697c6
blob + d4d4d5f96a1db1b627320a0b453ce60102c771d0
--- src/ngircd/ngircd.c
+++ src/ngircd/ngircd.c
@@ -68,6 +68,7 @@ static void Fill_Version PARAMS(( void ));
 static void Setup_FDStreams PARAMS(( int fd ));
 
 static bool NGIRCd_Init PARAMS(( bool ));
+
 
 /**
  * The main() function of ngIRCd.
@@ -723,4 +724,5 @@ NGIRCd_Init( bool NGIRCd_NoDaemon ) 
 	return false;
 }
 
+
 /* -eof- */
blob - 7d65510e906ad121dd97cbe817d4bca1a3f3a7ca
blob + 688a8f02dcf1871605ca47442f17b1ab93bbeb66
--- src/ngircd/sighandlers.c
+++ src/ngircd/sighandlers.c
@@ -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
@@ -139,7 +155,31 @@ static void Signal_Handler(int Signal)
 		/* child-process exited, avoid zombies */
 		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