mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-08 08:07:23 +03:00
Avoid redundant requests of announce entries from libtorrent
PR #21949.
This commit is contained in:
parent
2d1c4fc809
commit
a180162405
2 changed files with 9 additions and 19 deletions
|
@ -5541,8 +5541,6 @@ void SessionImpl::readAlerts()
|
||||||
|
|
||||||
// Some torrents may become "finished" after different alerts handling.
|
// Some torrents may become "finished" after different alerts handling.
|
||||||
processPendingFinishedTorrents();
|
processPendingFinishedTorrents();
|
||||||
|
|
||||||
processTrackerStatuses();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionImpl::handleAddTorrentAlert(const lt::add_torrent_alert *alert)
|
void SessionImpl::handleAddTorrentAlert(const lt::add_torrent_alert *alert)
|
||||||
|
@ -6232,7 +6230,10 @@ void SessionImpl::handleTrackerAlert(const lt::tracker_alert *alert)
|
||||||
if (!torrent)
|
if (!torrent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const auto prevSize = m_updatedTrackerStatuses.size();
|
||||||
QMap<int, int> &updateInfo = m_updatedTrackerStatuses[torrent->nativeHandle()][std::string(alert->tracker_url())][alert->local_endpoint];
|
QMap<int, int> &updateInfo = m_updatedTrackerStatuses[torrent->nativeHandle()][std::string(alert->tracker_url())][alert->local_endpoint];
|
||||||
|
if (prevSize < m_updatedTrackerStatuses.size())
|
||||||
|
updateTrackerEntryStatuses(torrent->nativeHandle());
|
||||||
|
|
||||||
if (alert->type() == lt::tracker_reply_alert::alert_type)
|
if (alert->type() == lt::tracker_reply_alert::alert_type)
|
||||||
{
|
{
|
||||||
|
@ -6294,17 +6295,6 @@ void SessionImpl::handleTorrentConflictAlert(const lt::torrent_conflict_alert *a
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SessionImpl::processTrackerStatuses()
|
|
||||||
{
|
|
||||||
if (m_updatedTrackerStatuses.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto it = m_updatedTrackerStatuses.cbegin(); it != m_updatedTrackerStatuses.cend(); ++it)
|
|
||||||
updateTrackerEntryStatuses(it.key(), it.value());
|
|
||||||
|
|
||||||
m_updatedTrackerStatuses.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SessionImpl::saveStatistics() const
|
void SessionImpl::saveStatistics() const
|
||||||
{
|
{
|
||||||
if (!m_isStatisticsDirty)
|
if (!m_isStatisticsDirty)
|
||||||
|
@ -6329,20 +6319,21 @@ void SessionImpl::loadStatistics()
|
||||||
m_previouslyUploaded = value[u"AlltimeUL"_s].toLongLong();
|
m_previouslyUploaded = value[u"AlltimeUL"_s].toLongLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionImpl::updateTrackerEntryStatuses(lt::torrent_handle torrentHandle, QHash<std::string, QHash<lt::tcp::endpoint, QMap<int, int>>> updatedTrackers)
|
void SessionImpl::updateTrackerEntryStatuses(lt::torrent_handle torrentHandle)
|
||||||
{
|
{
|
||||||
invokeAsync([this, torrentHandle = std::move(torrentHandle), updatedTrackers = std::move(updatedTrackers)]() mutable
|
invokeAsync([this, torrentHandle = std::move(torrentHandle)]() mutable
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::vector<lt::announce_entry> nativeTrackers = torrentHandle.trackers();
|
std::vector<lt::announce_entry> nativeTrackers = torrentHandle.trackers();
|
||||||
invoke([this, torrentHandle, nativeTrackers = std::move(nativeTrackers)
|
invoke([this, torrentHandle, nativeTrackers = std::move(nativeTrackers)]
|
||||||
, updatedTrackers = std::move(updatedTrackers)]
|
|
||||||
{
|
{
|
||||||
TorrentImpl *torrent = m_torrents.value(torrentHandle.info_hash());
|
TorrentImpl *torrent = m_torrents.value(torrentHandle.info_hash());
|
||||||
if (!torrent || torrent->isStopped())
|
if (!torrent || torrent->isStopped())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QHash<std::string, QHash<lt::tcp::endpoint, QMap<int, int>>> updatedTrackers = m_updatedTrackerStatuses.take(torrentHandle);
|
||||||
|
|
||||||
QHash<QString, TrackerEntryStatus> trackers;
|
QHash<QString, TrackerEntryStatus> trackers;
|
||||||
trackers.reserve(updatedTrackers.size());
|
trackers.reserve(updatedTrackers.size());
|
||||||
for (const lt::announce_entry &announceEntry : nativeTrackers)
|
for (const lt::announce_entry &announceEntry : nativeTrackers)
|
||||||
|
|
|
@ -546,7 +546,6 @@ namespace BitTorrent
|
||||||
void populateAdditionalTrackers();
|
void populateAdditionalTrackers();
|
||||||
void enableIPFilter();
|
void enableIPFilter();
|
||||||
void disableIPFilter();
|
void disableIPFilter();
|
||||||
void processTrackerStatuses();
|
|
||||||
void processTorrentShareLimits(TorrentImpl *torrent);
|
void processTorrentShareLimits(TorrentImpl *torrent);
|
||||||
void populateExcludedFileNamesRegExpList();
|
void populateExcludedFileNamesRegExpList();
|
||||||
void prepareStartup();
|
void prepareStartup();
|
||||||
|
@ -610,7 +609,7 @@ namespace BitTorrent
|
||||||
void saveStatistics() const;
|
void saveStatistics() const;
|
||||||
void loadStatistics();
|
void loadStatistics();
|
||||||
|
|
||||||
void updateTrackerEntryStatuses(lt::torrent_handle torrentHandle, QHash<std::string, QHash<lt::tcp::endpoint, QMap<int, int>>> updatedTrackers);
|
void updateTrackerEntryStatuses(lt::torrent_handle torrentHandle);
|
||||||
|
|
||||||
void handleRemovedTorrent(const TorrentID &torrentID, const QString &partfileRemoveError = {});
|
void handleRemovedTorrent(const TorrentID &torrentID, const QString &partfileRemoveError = {});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue