From e673fb0057265c0969a7632a057e41fa991bb8bd Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Tue, 10 Mar 2009 12:22:34 +0100 Subject: [PATCH] tackeling 30 sec ping timeout issues --- src/core/corenetwork.cpp | 7 +++++-- src/core/corenetwork.h | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index a3570441..dedd819e 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -41,6 +41,8 @@ CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session) _lastUsedServerIndex(0), _lastPingTime(0), + _maxPingCount(3), + _pingCount(0), // TODO make autowho configurable (possibly per-network) _autoWhoEnabled(true), @@ -516,13 +518,14 @@ void CoreNetwork::doAutoReconnect() { void CoreNetwork::sendPing() { uint now = QDateTime::currentDateTime().toTime_t(); - if(_lastPingTime != 0 && now - _lastPingTime <= (uint)(_pingTimer.interval() / 1000) + 1) { + if(_pingCount >= _maxPingCount && now - _lastPingTime <= (uint)(_pingTimer.interval() / 1000) + 1) { // the second check compares the actual elapsed time since the last ping and the pingTimer interval // if the interval is shorter then the actual elapsed time it means that this thread was somehow blocked // and unable to even handle a ping answer. So we ignore those misses. - disconnectFromIrc(false, QString("No Ping reply in %1 seconds.").arg(_pingTimer.interval() / 1000), true /* withReconnect */); + disconnectFromIrc(false, QString("No Ping reply in %1 seconds.").arg(_maxPingCount * _pingTimer.interval() / 1000), true /* withReconnect */); } else { _lastPingTime = now; + _pingCount++; userInputHandler()->handlePing(BufferInfo(), QString()); } } diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index c11aee84..0a07af94 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -106,7 +106,7 @@ public slots: Server usedServer() const; - inline void resetPingTimeout() { _lastPingTime = 0; } + inline void resetPingTimeout() { _pingCount = 0; } signals: void recvRawServerMsg(QString); @@ -178,6 +178,8 @@ private: QTimer _pingTimer; uint _lastPingTime; + uint _maxPingCount; + uint _pingCount; bool _autoWhoEnabled; QStringList _autoWhoQueue; -- 2.20.1