summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2012-01-24 02:55:53 +0100
committerAlexander Barton <alex@barton.de>2012-01-24 02:55:53 +0100
commit871760583cb4f90e908d3dac94679ce876d78c83 (patch)
treeb972c7345fed44674430f65ca39511bd7ee5f1de /src
parentbc20f9ec1076a67a81ed8e7c3489ffbdf3387e53 (diff)
downloadngircd-871760583cb4f90e908d3dac94679ce876d78c83.tar.gz
ngircd-871760583cb4f90e908d3dac94679ce876d78c83.zip
Enhance server command limits
This patch updates the limits for handling commands from a remote server:

 - "<user count> / 5 + <min>" using "<min>=10" during normal operation,
 - the above count multiplied with 5 while servers are syncing.

The intention is to a) make the limit dependent of the number of users
in the network (the more users, the more commands required to sync) and
b) to significantly rise this limit while servers are joining the network
to make the login and synchronization faster.
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/conn.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index f743d1f8..71dc939f 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -82,8 +82,8 @@
 #define SERVER_WAIT (NONE - 1)
 
 #define MAX_COMMANDS 3
-#define MAX_COMMANDS_SERVER 10
-#define MAX_COMMANDS_SERVICE MAX_COMMANDS_SERVER
+#define MAX_COMMANDS_SERVER_MIN 10
+#define MAX_COMMANDS_SERVICE 10
 
 
 static bool Handle_Write PARAMS(( CONN_ID Idx ));
@@ -1674,16 +1674,15 @@ Handle_Buffer(CONN_ID Idx)
 
 	assert(c != NULL);
 
-	/* Servers do get special command limits, so they can process
-	 * all the messages that are required while peering. */
+	/* Servers get special command limits that depend on the user count */
 	switch (Client_Type(c)) {
 	    case CLIENT_SERVER:
-		/* Allow servers to send more commands in the first 10 secods
+		maxcmd = (int)(Client_UserCount() / 5)
+		       + MAX_COMMANDS_SERVER_MIN;
+		/* Allow servers to handle even more commands while peering
 		 * to speed up server login and network synchronisation. */
-		if (starttime - Client_StartTime(c) < 10)
-			maxcmd = MAX_COMMANDS_SERVER * 5;
-		else
-			maxcmd = MAX_COMMANDS_SERVER;
+		if (Conn_LastPing(Idx) == 0)
+			maxcmd *= 5;
 		break;
 	    case CLIENT_SERVICE:
 		maxcmd = MAX_COMMANDS_SERVICE; break;