summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Samir <[email protected]>2024-08-22 16:15:37 +0300
committerAhmad Samir <[email protected]>2024-08-31 18:37:45 +0300
commit54d02df0fc85070613508ed11d6159df9c8e3db7 (patch)
tree6b9f770db61711a49bd1a6b3cce8882947aa6241
parent160d8f76468688892799149af57f02482719291f (diff)
QSocks5BindStore: use QBasicTimer instead of manipulating the timer id
Change-Id: Iefd8dba4fa9193f197ffbdb960fabae9b18bf952 Reviewed-by: MÃ¥rten Nordheim <[email protected]>
-rw-r--r--src/network/socket/qsocks5socketengine.cpp15
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)) {