mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-06 11:54:18 +00: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
@ -2892,28 +2892,41 @@ void SessionImpl::saveResumeData()
|
||||
++m_numResumeData;
|
||||
}
|
||||
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
while (m_numResumeData > 0)
|
||||
{
|
||||
const std::vector<lt::alert *> alerts = getPendingAlerts(lt::seconds {30});
|
||||
if (alerts.empty())
|
||||
{
|
||||
LogMsg(tr("Aborted saving resume data. Number of outstanding torrents: %1").arg(QString::number(m_numResumeData))
|
||||
, Log::CRITICAL);
|
||||
break;
|
||||
}
|
||||
const lt::seconds waitTime {5};
|
||||
const lt::seconds expireTime {30};
|
||||
const std::vector<lt::alert *> alerts = getPendingAlerts(waitTime);
|
||||
|
||||
bool hasWantedAlert = false;
|
||||
for (const lt::alert *a : alerts)
|
||||
{
|
||||
switch (a->type())
|
||||
{
|
||||
case lt::save_resume_data_failed_alert::alert_type:
|
||||
hasWantedAlert = true;
|
||||
--m_numResumeData;
|
||||
break;
|
||||
case lt::save_resume_data_alert::alert_type:
|
||||
hasWantedAlert = true;
|
||||
dispatchTorrentAlert(static_cast<const lt::torrent_alert *>(a));
|
||||
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…
x
Reference in New Issue
Block a user