mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-11 15:56:17 -07:00
Revise "save resume data" handling on shutdown
When shutting down, instead of waiting for all types of alert from libtorrent, now it only waits for specific alert types. This potentially help shorten the shutdown waiting time.
This commit is contained in:
parent
698284f00e
commit
a44bca3f07
1 changed files with 20 additions and 7 deletions
|
@ -2892,28 +2892,41 @@ void SessionImpl::saveResumeData()
|
||||||
++m_numResumeData;
|
++m_numResumeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QElapsedTimer timer;
|
||||||
|
timer.start();
|
||||||
|
|
||||||
while (m_numResumeData > 0)
|
while (m_numResumeData > 0)
|
||||||
{
|
{
|
||||||
const std::vector<lt::alert *> alerts = getPendingAlerts(lt::seconds {30});
|
const lt::seconds waitTime {5};
|
||||||
if (alerts.empty())
|
const lt::seconds expireTime {30};
|
||||||
{
|
const std::vector<lt::alert *> alerts = getPendingAlerts(waitTime);
|
||||||
LogMsg(tr("Aborted saving resume data. Number of outstanding torrents: %1").arg(QString::number(m_numResumeData))
|
|
||||||
, Log::CRITICAL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bool hasWantedAlert = false;
|
||||||
for (const lt::alert *a : alerts)
|
for (const lt::alert *a : alerts)
|
||||||
{
|
{
|
||||||
switch (a->type())
|
switch (a->type())
|
||||||
{
|
{
|
||||||
case lt::save_resume_data_failed_alert::alert_type:
|
case lt::save_resume_data_failed_alert::alert_type:
|
||||||
|
hasWantedAlert = true;
|
||||||
--m_numResumeData;
|
--m_numResumeData;
|
||||||
break;
|
break;
|
||||||
case lt::save_resume_data_alert::alert_type:
|
case lt::save_resume_data_alert::alert_type:
|
||||||
|
hasWantedAlert = true;
|
||||||
dispatchTorrentAlert(static_cast<const lt::torrent_alert *>(a));
|
dispatchTorrentAlert(static_cast<const lt::torrent_alert *>(a));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasWantedAlert)
|
||||||
|
{
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
else if (timer.hasExpired(lt::total_milliseconds(expireTime)))
|
||||||
|
{
|
||||||
|
LogMsg(tr("Aborted saving resume data. Number of outstanding torrents: %1").arg(QString::number(m_numResumeData))
|
||||||
|
, Log::CRITICAL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue