about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2010-12-29 14:19:51 +0100
committerAlexander Barton <alex@barton.de>2010-12-29 14:19:51 +0100
commitf37e495a2badf94fff2eaff24ed730dbceef94e0 (patch)
tree05bf8e9618a7f5283686d2f2d4db938941ae44f0
parent21cbf37db5647159eced6ed1275e0e2e6980155c (diff)
downloadngircd-f37e495a2badf94fff2eaff24ed730dbceef94e0.tar.gz
ngircd-f37e495a2badf94fff2eaff24ed730dbceef94e0.zip
Command throttling: introduce MAX_COMMANDS_SERVICE
New MAX_COMMANDS_SERVICE (currently set to MAX_COMMANDS_SERVER[10]),
so that services are handled like servers (and not regular users).
-rw-r--r--src/ngircd/conn.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 73a66bbb..51ab8fd3 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -82,6 +82,7 @@
 
 #define MAX_COMMANDS 3
 #define MAX_COMMANDS_SERVER 10
+#define MAX_COMMANDS_SERVICE MAX_COMMANDS_SERVER
 
 
 static bool Handle_Write PARAMS(( CONN_ID Idx ));
@@ -1530,7 +1531,7 @@ Read_Request( CONN_ID Idx )
 /**
  * Handle all data in the connection read-buffer.
  * Data is processed until no complete command is left in the read buffer,
- * or MAX_COMMANDS[_SERVER] commands were processed.
+ * or MAX_COMMANDS[_SERVER|_SERVICE] commands were processed.
  * When a fatal error occurs, the connection is shut down.
  * @param Idx Index of the connection.
  * @return number of bytes processed.
@@ -1555,8 +1556,12 @@ Handle_Buffer(CONN_ID Idx)
 
 	/* Servers do get special command limits, so they can process
 	 * all the messages that are required while peering. */
-	if (Client_Type(c) == CLIENT_SERVER)
-		maxcmd = MAX_COMMANDS_SERVER;
+	switch (Client_Type(c)) {
+	    case CLIENT_SERVER:
+		maxcmd = MAX_COMMANDS_SERVER; break;
+	    case CLIENT_SERVICE:
+		maxcmd = MAX_COMMANDS_SERVICE; break;
+	}
 
 	starttime = time(NULL);
 	for (i=0; i < maxcmd; i++) {