diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 2e762983e..20112c526 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -578,9 +578,10 @@ namespace aux { // indices into m_torrents to empty slots std::vector m_free_slots; + std::atomic_flag m_jobs_aborted = ATOMIC_FLAG_INIT; + #if TORRENT_USE_ASSERTS int m_magic = 0x1337; - std::atomic m_jobs_aborted{false}; #endif }; } diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index ac6caaeaa..2e884be45 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -3211,7 +3211,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit; void disk_io_thread::abort_jobs() { TORRENT_ASSERT(m_magic == 0x1337); - TORRENT_ASSERT(!m_jobs_aborted.exchange(true)); + if (m_jobs_aborted.test_and_set()) return; jobqueue_t jobs; m_disk_cache.clear(jobs);