@@ -5541,8 +5541,6 @@ void SessionImpl::readAlerts()
5541
5541
5542
5542
// Some torrents may become "finished" after different alerts handling.
5543
5543
processPendingFinishedTorrents ();
5544
-
5545
- processTrackerStatuses ();
5546
5544
}
5547
5545
5548
5546
void SessionImpl::handleAddTorrentAlert (const lt::add_torrent_alert *alert)
@@ -6232,7 +6230,10 @@ void SessionImpl::handleTrackerAlert(const lt::tracker_alert *alert)
6232
6230
if (!torrent)
6233
6231
return ;
6234
6232
6233
+ const auto prevSize = m_updatedTrackerStatuses.size ();
6235
6234
QMap<int , int > &updateInfo = m_updatedTrackerStatuses[torrent->nativeHandle ()][std::string (alert->tracker_url ())][alert->local_endpoint ];
6235
+ if (prevSize < m_updatedTrackerStatuses.size ())
6236
+ updateTrackerEntryStatuses (torrent->nativeHandle ());
6236
6237
6237
6238
if (alert->type () == lt::tracker_reply_alert::alert_type)
6238
6239
{
@@ -6294,17 +6295,6 @@ void SessionImpl::handleTorrentConflictAlert(const lt::torrent_conflict_alert *a
6294
6295
}
6295
6296
#endif
6296
6297
6297
- void SessionImpl::processTrackerStatuses ()
6298
- {
6299
- if (m_updatedTrackerStatuses.isEmpty ())
6300
- return ;
6301
-
6302
- for (auto it = m_updatedTrackerStatuses.cbegin (); it != m_updatedTrackerStatuses.cend (); ++it)
6303
- updateTrackerEntryStatuses (it.key (), it.value ());
6304
-
6305
- m_updatedTrackerStatuses.clear ();
6306
- }
6307
-
6308
6298
void SessionImpl::saveStatistics () const
6309
6299
{
6310
6300
if (!m_isStatisticsDirty)
@@ -6329,20 +6319,21 @@ void SessionImpl::loadStatistics()
6329
6319
m_previouslyUploaded = value[u" AlltimeUL" _s].toLongLong ();
6330
6320
}
6331
6321
6332
- void SessionImpl::updateTrackerEntryStatuses (lt::torrent_handle torrentHandle, QHash<std::string, QHash<lt::tcp::endpoint, QMap< int , int >>> updatedTrackers )
6322
+ void SessionImpl::updateTrackerEntryStatuses (lt::torrent_handle torrentHandle)
6333
6323
{
6334
- invokeAsync ([this , torrentHandle = std::move (torrentHandle), updatedTrackers = std::move (updatedTrackers) ]() mutable
6324
+ invokeAsync ([this , torrentHandle = std::move (torrentHandle)]() mutable
6335
6325
{
6336
6326
try
6337
6327
{
6338
6328
std::vector<lt::announce_entry> nativeTrackers = torrentHandle.trackers ();
6339
- invoke ([this , torrentHandle, nativeTrackers = std::move (nativeTrackers)
6340
- , updatedTrackers = std::move (updatedTrackers)]
6329
+ invoke ([this , torrentHandle, nativeTrackers = std::move (nativeTrackers)]
6341
6330
{
6342
6331
TorrentImpl *torrent = m_torrents.value (torrentHandle.info_hash ());
6343
6332
if (!torrent || torrent->isStopped ())
6344
6333
return ;
6345
6334
6335
+ QHash<std::string, QHash<lt::tcp::endpoint, QMap<int , int >>> updatedTrackers = m_updatedTrackerStatuses.take (torrentHandle);
6336
+
6346
6337
QHash<QString, TrackerEntryStatus> trackers;
6347
6338
trackers.reserve (updatedTrackers.size ());
6348
6339
for (const lt::announce_entry &announceEntry : nativeTrackers)
0 commit comments