summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e9c0076)
Prior to this, the timer was simply running for 10 seconds from the
start of the query; which could timeout even while data was being received.
Large channel lists (i.e. Freenode) would over-run into the status buffer.
Now we utilize QBasicTimer to create a timer that can be easily
restarted everytime we receive a RPL_LIST. Inital timeout is 5 seconds
and 5 seconds after each RPL_LIST. We also now remove the timer after
receiving a RPL_LISTEND instead of letting it tick.
#include "corenetwork.h"
#include "coreuserinputhandler.h"
#include "corenetwork.h"
#include "coreuserinputhandler.h"
+constexpr auto kTimeoutMs = 5000;
+
INIT_SYNCABLE_OBJECT(CoreIrcListHelper)
QVariantList CoreIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters)
{
INIT_SYNCABLE_OBJECT(CoreIrcListHelper)
QVariantList CoreIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters)
{
return false;
_channelLists[netId] << ChannelDescription(channelName, userCount, topic);
return false;
_channelLists[netId] << ChannelDescription(channelName, userCount, topic);
+ if (_queryTimeoutByNetId.contains(netId))
+ _queryTimeoutByNetId[netId]->start(kTimeoutMs, this);
+
if (network) {
_channelLists[netId] = QList<ChannelDescription>();
network->userInputHandler()->handleList(BufferInfo(), query);
if (network) {
_channelLists[netId] = QList<ChannelDescription>();
network->userInputHandler()->handleList(BufferInfo(), query);
- _queryTimeout[startTimer(10000)] = netId;
+
+ auto timer = std::make_shared<QBasicTimer>();
+ timer->start(kTimeoutMs, this);
+ _queryTimeoutByNetId[netId] = timer;
+ _queryTimeoutByTimerId[timer->timerId()] = netId;
+
bool CoreIrcListHelper::endOfChannelList(const NetworkId &netId)
{
bool CoreIrcListHelper::endOfChannelList(const NetworkId &netId)
{
+ if (_queryTimeoutByNetId.contains(netId)) {
+ // If we recieved an actual RPL_LISTEND, remove the timer
+ int timerId = _queryTimeoutByNetId.take(netId)->timerId();
+ _queryTimeoutByTimerId.remove(timerId);
+ }
+
if (_queuedQuery.contains(netId)) {
// we're no longer interessted in the current data. drop it and issue a new request.
return dispatchQuery(netId, _queuedQuery.take(netId));
if (_queuedQuery.contains(netId)) {
// we're no longer interessted in the current data. drop it and issue a new request.
return dispatchQuery(netId, _queuedQuery.take(netId));
void CoreIrcListHelper::timerEvent(QTimerEvent *event)
{
void CoreIrcListHelper::timerEvent(QTimerEvent *event)
{
- int timerId = event->timerId();
- killTimer(timerId);
- NetworkId netId = _queryTimeout.take(timerId);
+ if (!_queryTimeoutByTimerId.contains(event->timerId())) {
+ IrcListHelper::timerEvent(event);
+ return;
+ }
+
+ NetworkId netId = _queryTimeoutByTimerId.take(event->timerId());
+ _queryTimeoutByNetId.remove(netId);
+
+ event->accept();
endOfChannelList(netId);
}
endOfChannelList(netId);
}
#ifndef COREIRCLISTHELPER_H
#define COREIRCLISTHELPER_H
#ifndef COREIRCLISTHELPER_H
#define COREIRCLISTHELPER_H
#include "irclisthelper.h"
#include "coresession.h"
#include "irclisthelper.h"
#include "coresession.h"
class QTimerEvent;
class CoreIrcListHelper : public IrcListHelper
class QTimerEvent;
class CoreIrcListHelper : public IrcListHelper
QHash<NetworkId, QString> _queuedQuery;
QHash<NetworkId, QList<ChannelDescription> > _channelLists;
QHash<NetworkId, QVariantList> _finishedChannelLists;
QHash<NetworkId, QString> _queuedQuery;
QHash<NetworkId, QList<ChannelDescription> > _channelLists;
QHash<NetworkId, QVariantList> _finishedChannelLists;
- QHash<int, NetworkId> _queryTimeout;
+ QHash<int, NetworkId> _queryTimeoutByTimerId;
+ QHash<NetworkId, std::shared_ptr<QBasicTimer>> _queryTimeoutByNetId;