Browse Source

Avoid blocking call when save resume data

PR #17755.
adaptive-webui-19844
Vladimir Golovnev 2 years ago committed by GitHub
parent
commit
0a4ee60ea0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/base/bittorrent/sessionimpl.cpp
  2. 3
      src/base/bittorrent/torrentimpl.cpp

9
src/base/bittorrent/sessionimpl.cpp

@ -2854,7 +2854,12 @@ void SessionImpl::saveResumeData()
if (isQueueingSystemEnabled()) if (isQueueingSystemEnabled())
saveTorrentsQueue(); saveTorrentsQueue();
generateResumeData();
for (const TorrentImpl *torrent : asConst(m_torrents))
{
torrent->nativeHandle().save_resume_data(lt::torrent_handle::only_if_modified);
++m_numResumeData;
}
while (m_numResumeData > 0) while (m_numResumeData > 0)
{ {
@ -2871,6 +2876,8 @@ void SessionImpl::saveResumeData()
switch (a->type()) switch (a->type())
{ {
case lt::save_resume_data_failed_alert::alert_type: case lt::save_resume_data_failed_alert::alert_type:
--m_numResumeData;
break;
case lt::save_resume_data_alert::alert_type: case lt::save_resume_data_alert::alert_type:
dispatchTorrentAlert(static_cast<const lt::torrent_alert *>(a)); dispatchTorrentAlert(static_cast<const lt::torrent_alert *>(a));
break; break;

3
src/base/bittorrent/torrentimpl.cpp

@ -682,7 +682,7 @@ bool TorrentImpl::connectPeer(const PeerAddress &peerAddress)
bool TorrentImpl::needSaveResumeData() const bool TorrentImpl::needSaveResumeData() const
{ {
return m_nativeHandle.need_save_resume_data(); return m_nativeStatus.need_save_resume;
} }
void TorrentImpl::saveResumeData() void TorrentImpl::saveResumeData()
@ -2006,7 +2006,6 @@ void TorrentImpl::handleFileErrorAlert(const lt::file_error_alert *p)
#ifdef QBT_USES_LIBTORRENT2 #ifdef QBT_USES_LIBTORRENT2
void TorrentImpl::handleFilePrioAlert(const lt::file_prio_alert *) void TorrentImpl::handleFilePrioAlert(const lt::file_prio_alert *)
{ {
if (m_nativeHandle.need_save_resume_data())
m_session->handleTorrentNeedSaveResumeData(this); m_session->handleTorrentNeedSaveResumeData(this);
} }
#endif #endif

Loading…
Cancel
Save