From d2d35b69fdf43e40f343c45098a933a8999d7649 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 8 Jul 2018 15:31:54 +0200 Subject: [PATCH] raise priority of cache_flushed_alert and post it unconditionally when triggered explicily by the client --- include/libtorrent/alert_types.hpp | 2 +- include/libtorrent/torrent.hpp | 2 +- src/torrent.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 50f83706a..f627fc1a2 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -1630,7 +1630,7 @@ namespace libtorrent // internal cache_flushed_alert(aux::stack_allocator& alloc, torrent_handle const& h); - TORRENT_DEFINE_ALERT(cache_flushed_alert, 58) + TORRENT_DEFINE_ALERT_PRIO(cache_flushed_alert, 58, alert_priority_high) static const int static_category = alert::storage_notification; }; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 778a9886e..0924213ab 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -1164,7 +1164,7 @@ namespace libtorrent void on_storage_moved(disk_io_job const* j); void on_save_resume_data(disk_io_job const* j); void on_file_renamed(disk_io_job const* j); - void on_cache_flushed(disk_io_job const* j); + void on_cache_flushed(disk_io_job const* j, bool manually_triggered); // this is used when a torrent is being removed.It synchronizes with the // disk thread diff --git a/src/torrent.cpp b/src/torrent.cpp index 85343df3b..2c251489a 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -8701,7 +8701,7 @@ namespace { // we need to keep the object alive during this operation inc_refcount("release_files"); m_ses.disk_thread().async_release_files(m_storage.get() - , boost::bind(&torrent::on_cache_flushed, shared_from_this(), _1)); + , boost::bind(&torrent::on_cache_flushed, shared_from_this(), _1, false)); } // this torrent just completed downloads, which means it will fall @@ -9881,17 +9881,17 @@ namespace { } inc_refcount("release_files"); m_ses.disk_thread().async_release_files(m_storage.get() - , boost::bind(&torrent::on_cache_flushed, shared_from_this(), _1)); + , boost::bind(&torrent::on_cache_flushed, shared_from_this(), _1, true)); } - void torrent::on_cache_flushed(disk_io_job const*) + void torrent::on_cache_flushed(disk_io_job const*, bool const manually_triggered) { dec_refcount("release_files"); TORRENT_ASSERT(is_single_thread()); if (m_ses.is_aborted()) return; - if (alerts().should_post()) + if (manually_triggered || alerts().should_post()) alerts().emplace_alert(get_handle()); }