summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2008-11-12 01:23:33 +0100
committerAlexander Barton <alex@barton.de>2008-11-12 01:26:04 +0100
commit9f067a059d9f64c68a73a2f7fbf5308ee342fe2a (patch)
tree68fafcb2027b3f41ac85bdbabf2f7b305f9d1411
parent5a91d621009d6a0f3b8e5ff054aa6ae7e3195191 (diff)
downloadngircd-9f067a059d9f64c68a73a2f7fbf5308ee342fe2a.tar.gz
ngircd-9f067a059d9f64c68a73a2f7fbf5308ee342fe2a.zip
Connection counter: count outgoing connections as well.
This patch lets ngIRCd count outgoing connections as well as incoming
connections (up to now only outgoing connections have been counted). This
change is required because the Conn_Close() function doesn't know whether
it closes an outgoing connection or not and therefore would decrement the
counter below zero when an outgoing connection existed -- which would
trigger an assert() call ...

Please note that this patch changes the (so far undocumented but now fixed)
behaviour of the "MaxConnections" configuration option to account the sum
of the in- and outbound connections!
-rw-r--r--doc/sample-ngircd.conf4
-rw-r--r--man/ngircd.conf.5.tmpl4
-rw-r--r--src/ngircd/conn.c10
3 files changed, 11 insertions, 7 deletions
diff --git a/doc/sample-ngircd.conf b/doc/sample-ngircd.conf
index 665edae7..459d51d4 100644
--- a/doc/sample-ngircd.conf
+++ b/doc/sample-ngircd.conf
@@ -126,8 +126,8 @@
 	;ConnectIPv6 = yes
 	;ConnectIPv4 = yes
 
-	# Maximum number of simultaneous connection the server is allowed
-	# to accept (0: unlimited):
+	# Maximum number of simultaneous in- and outbound connections the
+	# server is allowed to accept (0: unlimited):
 	;MaxConnections = 0
 
 	# Maximum number of simultaneous connections from a single IP address
diff --git a/man/ngircd.conf.5.tmpl b/man/ngircd.conf.5.tmpl
index cdf4a425..14baf209 100644
--- a/man/ngircd.conf.5.tmpl
+++ b/man/ngircd.conf.5.tmpl
@@ -193,8 +193,8 @@ Set this to no if you do not want ngircd to connect to other irc servers using i
 Default: Yes.
 .TP
 \fBMaxConnections\fR
-Maximum number of simultaneous connection the server is allowed to accept
-(0: unlimited). Default: 0.
+Maximum number of simultaneous in- and outbound connections the server is
+allowed to accept (0: unlimited). Default: 0.
 .TP
 \fBMaxConnectionsIP\fR
 Maximum number of simultaneous connections from a single IP address that
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 0b21d3a1..f0a97f9c 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -116,6 +116,7 @@ cb_listen(int sock, short irrelevant)
 	(void) irrelevant;
 	if (New_Connection( sock ) >= 0)
 		NumConnections++;
+	LogDebug("Total number of connections now %ld.", NumConnections);
 }
 
 
@@ -130,6 +131,7 @@ cb_listen_ssl(int sock, short irrelevant)
 		return;
 
 	NumConnections++;
+	LogDebug("Total number of connections now %ld.", NumConnections);
 	io_event_setcb(My_Connections[fd].sock, cb_clientserver_ssl);
 }
 #endif
@@ -1035,7 +1037,8 @@ Conn_Close( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient )
 	assert(NumConnections > 0);
 	if (NumConnections)
 		NumConnections--;
-	LogDebug("Shutdown of connection %d completed", Idx );
+	LogDebug("Shutdown of connection %d completed, %ld connection%s left.",
+		 Idx, NumConnections, NumConnections != 1 ? "s" : "");
 } /* Conn_Close */
 
 
@@ -1717,8 +1720,9 @@ New_Server( int Server , ng_ipaddr_t *dest)
 		Conf_Server[Server].conn_id = NONE;
 	}
 #endif
-	LogDebug("Registered new connection %d on socket %d.",
-				new_sock, My_Connections[new_sock].sock );
+	NumConnections++;
+	LogDebug("Registered new connection %d on socket %d (%ld in total).",
+		 new_sock, My_Connections[new_sock].sock, NumConnections);
 	Conn_OPTION_ADD( &My_Connections[new_sock], CONN_ISCONNECTING );
 } /* New_Server */