diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index d4aae4461..aaa5dbcb3 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -518,14 +518,6 @@ void bind_torrent_handle() .value("locked", file_open_mode::locked) ; -#ifndef TORRENT_NO_DEPRECATE - class_("pool_file_status") - .add_property("file_index", make_getter((&open_file_state::file_index), by_value())) - .def_readonly("last_use", &open_file_state::last_use) - .def_readonly("open_mode", &open_file_state::open_mode) - ; -#endif - enum_("file_progress_flags") .value("piece_granularity", torrent_handle::piece_granularity) ; diff --git a/include/libtorrent/disk_interface.hpp b/include/libtorrent/disk_interface.hpp index db8f97ccf..f05948fcb 100644 --- a/include/libtorrent/disk_interface.hpp +++ b/include/libtorrent/disk_interface.hpp @@ -119,7 +119,7 @@ namespace libtorrent struct TORRENT_EXTRA_EXPORT disk_interface { - enum flags_t + enum flags_t : std::uint8_t { sequential_access = 0x1, @@ -137,7 +137,7 @@ namespace libtorrent virtual storage_interface* get_torrent(storage_index_t) = 0; virtual void async_read(storage_index_t storage, peer_request const& r - , std::function handler + , std::function handler , void* requester, std::uint8_t flags = 0) = 0; virtual bool async_write(storage_index_t storage, peer_request const& r , char const* buf, std::shared_ptr o diff --git a/include/libtorrent/disk_io_job.hpp b/include/libtorrent/disk_io_job.hpp index 596d19265..6c9523cf8 100644 --- a/include/libtorrent/disk_io_job.hpp +++ b/include/libtorrent/disk_io_job.hpp @@ -147,7 +147,7 @@ namespace libtorrent // this is called when operation completes - using read_handler = std::function; + using read_handler = std::function; using write_handler = std::function; using hash_handler = std::function; using move_handler = std::function; diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 63f9d9420..2a72645d0 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -299,7 +299,7 @@ namespace libtorrent void async_read(storage_index_t storage, peer_request const& r , std::function handler, void* requester, std::uint8_t flags = 0) override; + , std::uint32_t flags, storage_error const& se)> handler, void* requester, std::uint8_t flags = 0) override; bool async_write(storage_index_t storage, peer_request const& r , char const* buf, std::shared_ptr o , std::function handler @@ -462,7 +462,7 @@ namespace libtorrent void kick_hasher(cached_piece_entry* pe, std::unique_lock& l); // flags to pass in to flush_cache() - enum flush_flags_t + enum flush_flags_t : std::uint32_t { // only flush read cache (this is cheap) flush_read_cache = 1, @@ -475,9 +475,9 @@ namespace libtorrent // used for asserts and only applies for fence jobs flush_expect_clear = 8 }; - void flush_cache(storage_interface* storage, int flags, jobqueue_t& completed_jobs, std::unique_lock& l); + void flush_cache(storage_interface* storage, std::uint32_t flags, jobqueue_t& completed_jobs, std::unique_lock& l); void flush_expired_write_blocks(jobqueue_t& completed_jobs, std::unique_lock& l); - void flush_piece(cached_piece_entry* pe, int flags, jobqueue_t& completed_jobs, std::unique_lock& l); + void flush_piece(cached_piece_entry* pe, std::uint32_t flags, jobqueue_t& completed_jobs, std::unique_lock& l); int try_flush_hashed(cached_piece_entry* p, int cont_blocks, jobqueue_t& completed_jobs, std::unique_lock& l); diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 3f08e50c3..e0ba9f00b 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -208,9 +208,9 @@ namespace libtorrent // error. If there's an error, the ``storage_error`` must be filled out // to represent the error that occurred. virtual int readv(span bufs - , piece_index_t piece, int offset, int flags, storage_error& ec) = 0; + , piece_index_t piece, int offset, std::uint32_t flags, storage_error& ec) = 0; virtual int writev(span bufs - , piece_index_t piece, int offset, int flags, storage_error& ec) = 0; + , piece_index_t piece, int offset, std::uint32_t flags, storage_error& ec) = 0; // This function is called when first checking (or re-checking) the // storage for a torrent. It should return true if any of the files that @@ -398,9 +398,9 @@ namespace libtorrent virtual bool tick() override; int readv(span bufs - , piece_index_t piece, int offset, int flags, storage_error& ec) override; + , piece_index_t piece, int offset, std::uint32_t flags, storage_error& ec) override; int writev(span bufs - , piece_index_t piece, int offset, int flags, storage_error& ec) override; + , piece_index_t piece, int offset, std::uint32_t flags, storage_error& ec) override; // if the files in this storage are mapped, returns the mapped // file_storage, otherwise returns the original file_storage object. diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 55bf3b0f6..3cfa8724d 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -116,10 +116,10 @@ namespace libtorrent #endif // DEBUG_DISK_THREAD - int file_flags_for_job(disk_io_job* j + std::uint32_t file_flags_for_job(disk_io_job* j , bool const coalesce_buffers) { - int ret = 0; + std::uint32_t ret = 0; if (!(j->flags & disk_interface::sequential_access)) ret |= file::random_access; if (coalesce_buffers) ret |= file::coalesce_buffers; return ret; @@ -658,7 +658,7 @@ namespace libtorrent DLOG("]\n"); #endif - int const file_flags = m_settings.get_bool(settings_pack::coalesce_writes) + std::uint32_t const file_flags = m_settings.get_bool(settings_pack::coalesce_writes) ? file::coalesce_buffers : static_cast(0); // issue the actual write operation @@ -820,7 +820,7 @@ namespace libtorrent } } - void disk_io_thread::flush_piece(cached_piece_entry* pe, int flags + void disk_io_thread::flush_piece(cached_piece_entry* pe, std::uint32_t const flags , jobqueue_t& completed_jobs, std::unique_lock& l) { TORRENT_ASSERT(l.owns_lock()); @@ -853,7 +853,7 @@ namespace libtorrent } } - void disk_io_thread::flush_cache(storage_interface* storage, int const flags + void disk_io_thread::flush_cache(storage_interface* storage, std::uint32_t const flags , jobqueue_t& completed_jobs, std::unique_lock& l) { if (storage) @@ -1224,7 +1224,7 @@ namespace libtorrent time_point const start_time = clock_type::now(); - int const file_flags = file_flags_for_job(j + std::uint32_t const file_flags = file_flags_for_job(j , m_settings.get_bool(settings_pack::coalesce_reads)); iovec_t b = {j->buffer.disk_block, std::size_t(j->d.io.buffer_size)}; @@ -1300,7 +1300,7 @@ namespace libtorrent // can remove them. We can now release the cache std::mutex and dive into the // disk operations. - int const file_flags = file_flags_for_job(j + std::uint32_t const file_flags = file_flags_for_job(j , m_settings.get_bool(settings_pack::coalesce_reads)); time_point const start_time = clock_type::now(); @@ -1459,7 +1459,7 @@ namespace libtorrent time_point const start_time = clock_type::now(); iovec_t const b = {j->buffer.disk_block, std::size_t(j->d.io.buffer_size)}; - int const file_flags = file_flags_for_job(j + std::uint32_t const file_flags = file_flags_for_job(j , m_settings.get_bool(settings_pack::coalesce_writes)); m_stats_counters.inc_stats_counter(counters::num_writing_threads, 1); @@ -1551,8 +1551,8 @@ namespace libtorrent } void disk_io_thread::async_read(storage_index_t storage, peer_request const& r - , std::function handler - , void* requester, std::uint8_t const flags) + , std::function handler, void* requester, std::uint8_t const flags) { TORRENT_ASSERT(r.length <= m_disk_cache.block_size()); TORRENT_ASSERT(r.length <= 16 * 1024); @@ -2147,7 +2147,7 @@ namespace libtorrent int const piece_size = j->storage->files().piece_size(j->piece); int const block_size = m_disk_cache.block_size(); int const blocks_in_piece = (piece_size + block_size - 1) / block_size; - int const file_flags = file_flags_for_job(j + std::uint32_t const file_flags = file_flags_for_job(j , m_settings.get_bool(settings_pack::coalesce_reads)); iovec_t iov; @@ -2192,7 +2192,7 @@ namespace libtorrent status_t disk_io_thread::do_hash(disk_io_job* j, jobqueue_t& /* completed_jobs */ ) { int const piece_size = j->storage->files().piece_size(j->piece); - int const file_flags = file_flags_for_job(j + std::uint32_t const file_flags = file_flags_for_job(j , m_settings.get_bool(settings_pack::coalesce_reads)); std::unique_lock l(m_cache_mutex); diff --git a/src/storage.cpp b/src/storage.cpp index d74b381fa..313bd3bdc 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -614,9 +614,10 @@ namespace libtorrent } int default_storage::readv(span bufs - , piece_index_t const piece, int offset, int flags, storage_error& ec) + , piece_index_t const piece, int const offset + , std::uint32_t const flags, storage_error& ec) { - read_fileop op(*this, static_cast(flags)); + read_fileop op(*this, flags); #ifdef TORRENT_SIMULATE_SLOW_READ std::this_thread::sleep_for(seconds(1)); @@ -625,9 +626,10 @@ namespace libtorrent } int default_storage::writev(span bufs - , piece_index_t const piece, int offset, int flags, storage_error& ec) + , piece_index_t const piece, int const offset + , std::uint32_t const flags, storage_error& ec) { - write_fileop op(*this, static_cast(flags)); + write_fileop op(*this, flags); return readwritev(files(), bufs, piece, offset, op, ec); } @@ -770,12 +772,12 @@ namespace libtorrent status_t move_storage(std::string const&, int, storage_error&) override { return status_t::no_error; } int readv(span bufs - , piece_index_t, int, int, storage_error&) override + , piece_index_t, int, std::uint32_t, storage_error&) override { return bufs_size(bufs); } int writev(span bufs - , piece_index_t, int, int, storage_error&) override + , piece_index_t, int, std::uint32_t, storage_error&) override { return bufs_size(bufs); } @@ -803,7 +805,7 @@ namespace libtorrent void initialize(storage_error&) override {} int readv(span bufs - , piece_index_t, int, int, storage_error&) override + , piece_index_t, int, std::uint32_t, storage_error&) override { int ret = 0; for (auto const& b : bufs) @@ -814,7 +816,7 @@ namespace libtorrent return 0; } int writev(span bufs - , piece_index_t, int, int, storage_error&) override + , piece_index_t, int, std::uint32_t, storage_error&) override { int ret = 0; for (auto const& b : bufs) diff --git a/test/test_block_cache.cpp b/test/test_block_cache.cpp index fd5805b63..7e5529a18 100644 --- a/test/test_block_cache.cpp +++ b/test/test_block_cache.cpp @@ -50,12 +50,12 @@ struct test_storage_impl : storage_interface void initialize(storage_error& ec) override {} int readv(span bufs - , piece_index_t piece, int offset, int flags, storage_error& ec) override + , piece_index_t piece, int offset, std::uint32_t flags, storage_error& ec) override { return bufs_size(bufs); } int writev(span bufs - , piece_index_t piece, int offset, int flags, storage_error& ec) override + , piece_index_t piece, int offset, std::uint32_t flags, storage_error& ec) override { return bufs_size(bufs); } diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index f363b85c8..44090f28d 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -71,7 +71,7 @@ bool on_alert(alert const* a) // simulate a full disk struct test_storage : default_storage { - explicit test_storage(storage_params const& params, file_pool& pool) + test_storage(storage_params const& params, file_pool& pool) : default_storage(params, pool) , m_written(0) , m_limit(16 * 1024 * 2) @@ -90,7 +90,7 @@ struct test_storage : default_storage span bufs , piece_index_t piece_index , int offset - , int flags + , std::uint32_t const flags , storage_error& se) override { std::unique_lock l(m_mutex);