Make rate limiting penalties less severe
authorclinton <clinton@unknownlamer.org>
Thu, 13 Nov 2008 09:11:10 +0000 (09:11 +0000)
committerclinton <clinton@unknownlamer.org>
Thu, 13 Nov 2008 09:11:10 +0000 (09:11 +0000)
* The max rate limit penalty is now 20 instead of 5 making the bot
  more responsive without making it flood; this seems like a
  reasonable value but may need to be further tweaked
* No longer unconditionally add `1' to penalty to decrease the
  likelihood of the queue being saturated and never getting further
  than popping the first message

source/ServerQueue.C
source/ServerQueue.H

index 9ed8a83..e927c1c 100644 (file)
@@ -25,6 +25,8 @@
 #include "ServerQueue.H"
 #include "Utils.H"
 
+int ServerQueue::max_penalty = 20;
+
 ServerQueue::ServerQueue(Socket * s, bool d)
   : Queue(s,d), penalty(0)
 {
@@ -90,10 +92,10 @@ ServerQueue::flush()
       penalty--;
     }
 
-  while (!serverQueue.empty() && (penalty < 5)) 
+  while (!serverQueue.empty() && (penalty < max_penalty)) 
     {
       ServerQueueItem * sqi = serverQueue.front ();
-      penalty += sqi->penalty + sqi->getLine().length()/100 + 1;
+      penalty += sqi->penalty + sqi->getLine().length()/100;
 
       bool res = sendLine(sqi->getLine());
 
index 2ae808f..a261248 100644 (file)
@@ -59,6 +59,8 @@ class ServerQueue : public Queue {
   int penalty;
   BotMutex queue_mutex;
 
+  static int max_penalty;
+
 public:
   ServerQueue(Socket *, bool);
   ~ServerQueue();