From: Manuel Nickschas Date: Tue, 17 Mar 2009 21:46:18 +0000 (+0100) Subject: Improve flood control a bit X-Git-Tag: 0.4.1~6 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=a71514b17a3e533454d3accfc367b48f6358aa18 Improve flood control a bit * Increase token refill rate to 2.2 seconds, should be safer * Empty send queue on disconnect so we don't get flooded off again This still needs some love; a bunch of very long lines still causes Excess Flood in Freenode. I suspect we'll have to introduce a byte rate limit in addition to the line rate limit :/ --- diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index dedd819e..b89c403a 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -192,6 +192,7 @@ void CoreNetwork::disconnectFromIrc(bool requested, const QString &reason, bool _autoReconnectCount = 0; // prohibiting auto reconnect } disablePingTimeout(); + _msgQueue.clear(); IrcUser *me_ = me(); if(me_) { @@ -327,10 +328,10 @@ void CoreNetwork::socketInitialized() { } // TokenBucket to avoid sending too much at once - _messagesPerSecond = 1; + _messageDelay = 2200; // this seems to be a safe value (2.2 seconds delay) _burstSize = 5; - _tokenBucket = 5; // init with a full bucket - _tokenBucketTimer.start(_messagesPerSecond * 1000); + _tokenBucket = _burstSize; // init with a full bucket + _tokenBucketTimer.start(_messageDelay); if(!server.password.isEmpty()) { putRawLine(serverEncode(QString("PASS %1").arg(server.password))); @@ -341,6 +342,7 @@ void CoreNetwork::socketInitialized() { void CoreNetwork::socketDisconnected() { disablePingTimeout(); + _msgQueue.clear(); _autoWhoCycleTimer.stop(); _autoWhoTimer.stop(); diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index 0a07af94..095e0fed 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -190,7 +190,7 @@ private: QTimer _autoWhoTimer, _autoWhoCycleTimer; QTimer _tokenBucketTimer; - int _messagesPerSecond; // token refill speed + int _messageDelay; // token refill speed in ms int _burstSize; // size of the token bucket int _tokenBucket; // the virtual bucket that holds the tokens QList _msgQueue;