diff options
Diffstat (limited to 'src/network/socket/qsocks5socketengine.cpp')
| -rw-r--r-- | src/network/socket/qsocks5socketengine.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index d3b9a32b227..f6dc0c6855e 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -21,6 +21,7 @@ #include <qendian.h> #include <qnetworkinterface.h> +#include <QtCore/qbasictimer.h> #include <QtCore/qpointer.h> #include <memory> @@ -295,7 +296,7 @@ protected: void timerEvent(QTimerEvent * event) override; QRecursiveMutex mutex; - int sweepTimerId = -1; + QBasicTimer sweepTimer; //socket descriptor, data, timestamp QHash<qintptr, QSocks5BindData *> store; }; @@ -323,8 +324,8 @@ void QSocks5BindStore::add(qintptr socketDescriptor, QSocks5BindData *bindData) store.insert(socketDescriptor, bindData); // start sweep timer if not started - if (sweepTimerId == -1) - sweepTimerId = startTimer(1min); + if (!sweepTimer.isActive()) + sweepTimer.start(1min, this); } bool QSocks5BindStore::contains(qintptr socketDescriptor) @@ -350,17 +351,15 @@ QSocks5BindData *QSocks5BindStore::retrieve(qintptr socketDescriptor) QSOCKS5_DEBUG << "__ERROR__ binddata == 0"; } // stop the sweep timer if not needed - if (store.isEmpty()) { - killTimer(sweepTimerId); - sweepTimerId = -1; - } + if (store.isEmpty()) + sweepTimer.stop(); return bindData; } void QSocks5BindStore::timerEvent(QTimerEvent * event) { QMutexLocker lock(&mutex); - if (event->timerId() == sweepTimerId) { + if (event->id() == sweepTimer.id()) { QSOCKS5_DEBUG << "QSocks5BindStore performing sweep"; for (auto it = store.begin(), end = store.end(); it != end;) { if (it.value()->timeStamp.hasExpired(350000)) { |
