Browse Source

Try to detect system wake-up event

PR #18934.
Closes #17898.
adaptive-webui-19844
Vladimir Golovnev 2 years ago committed by GitHub
parent
commit
58ae98026b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      src/base/bittorrent/sessionimpl.cpp
  2. 4
      src/base/bittorrent/sessionimpl.h

15
src/base/bittorrent/sessionimpl.cpp

@ -1470,6 +1470,21 @@ void SessionImpl::endStartup(ResumeSessionContext *context) @@ -1470,6 +1470,21 @@ void SessionImpl::endStartup(ResumeSessionContext *context)
m_resumeDataTimer->start();
}
m_wakeupCheckTimer = new QTimer(this);
connect(m_wakeupCheckTimer, &QTimer::timeout, this, [this]
{
const auto now = QDateTime::currentDateTime();
if (m_wakeupCheckTimestamp.secsTo(now) > 100)
{
LogMsg(tr("System wake-up event detected. Re-announcing to all the trackers..."));
reannounceToAllTrackers();
}
m_wakeupCheckTimestamp = QDateTime::currentDateTime();
});
m_wakeupCheckTimestamp = QDateTime::currentDateTime();
m_wakeupCheckTimer->start(30s);
m_isRestored = true;
emit startupProgressUpdated(100);
emit restored();

4
src/base/bittorrent/sessionimpl.h

@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
#include <libtorrent/torrent_handle.hpp>
#include <QtContainerFwd>
#include <QDateTime>
#include <QElapsedTimer>
#include <QHash>
#include <QPointer>
@ -773,6 +774,9 @@ namespace BitTorrent @@ -773,6 +774,9 @@ namespace BitTorrent
bool m_isPortMappingEnabled = false;
QHash<quint16, std::vector<lt::port_mapping_t>> m_mappedPorts;
QTimer *m_wakeupCheckTimer = nullptr;
QDateTime m_wakeupCheckTimestamp;
friend void Session::initInstance();
friend void Session::freeInstance();
friend Session *Session::instance();

Loading…
Cancel
Save