From f7c90620195eb765b4f84bf3acc25bd7c07a7dd7 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 19 Mar 2016 01:44:21 -0400 Subject: [PATCH] deprecate more parts of explicit cache as well as fixing typos of TORRENT_NO_DEPRECATE preprocessor tests --- bindings/python/src/create_torrent.cpp | 5 ++++- examples/make_torrent.cpp | 2 +- include/libtorrent/aux_/session_impl.hpp | 2 +- include/libtorrent/create_torrent.hpp | 11 ++++++----- include/libtorrent/disk_interface.hpp | 4 ++-- include/libtorrent/disk_io_job.hpp | 2 +- include/libtorrent/disk_io_thread.hpp | 4 ++-- include/libtorrent/settings_pack.hpp | 6 +++--- include/libtorrent/torrent.hpp | 2 +- src/block_cache.cpp | 11 +++++++---- src/disk_io_thread.cpp | 10 +++++----- src/session_handle.cpp | 2 +- src/session_impl.cpp | 4 ++-- src/torrent.cpp | 4 ++-- test/test_checking.cpp | 3 ++- test/test_remap_files.cpp | 2 +- 16 files changed, 41 insertions(+), 33 deletions(-) diff --git a/bindings/python/src/create_torrent.cpp b/bindings/python/src/create_torrent.cpp index 540813b79..d8e99bed8 100644 --- a/bindings/python/src/create_torrent.cpp +++ b/bindings/python/src/create_torrent.cpp @@ -198,7 +198,7 @@ void bind_create_torrent() .def(init()) .def(init(arg("ti"))) .def(init((arg("storage"), arg("piece_size") = 0 - , arg("pad_file_limit") = -1, arg("flags") = int(libtorrent::create_torrent::optimize)))) + , arg("pad_file_limit") = -1, arg("flags") = int(libtorrent::create_torrent::optimize_alignment)))) .def("generate", &create_torrent::generate) @@ -220,7 +220,10 @@ void bind_create_torrent() ; enum_("create_torrent_flags_t") +#ifndef TORRENT_NO_DEPRECATE .value("optimize", create_torrent::optimize) +#endif + .value("optimize_alignment", create_torrent::optimize_alignment) .value("merkle", create_torrent::merkle) .value("modification_time", create_torrent::modification_time) .value("symlinks", create_torrent::symlinks) diff --git a/examples/make_torrent.cpp b/examples/make_torrent.cpp index e441b1626..281451367 100644 --- a/examples/make_torrent.cpp +++ b/examples/make_torrent.cpp @@ -264,7 +264,7 @@ int main(int argc, char* argv[]) case 'p': ++i; pad_file_limit = atoi(argv[i]); - flags |= create_torrent::optimize; + flags |= create_torrent::optimize_alignment; break; case 's': ++i; diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index a0cab6bf4..429f74cac 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -933,7 +933,7 @@ namespace libtorrent // torrents. int m_auto_scrape_time_scaler; -#ifndef TORRENT_NO_DEPRECATED +#ifndef TORRENT_NO_DEPRECATE // the index of the torrent that we'll // refresh the next time int m_next_explicit_cache_torrent; diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index 905386d0a..ed9d4008d 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -114,7 +114,7 @@ namespace libtorrent // files, to keep the impact down for clients that don't support // them. optimize_alignment = 1, -#ifndef TORRENT_NO_DEPRECATED +#ifndef TORRENT_NO_DEPRECATE // same as optimize_alignment, for backwards compatibility optimize = 1, #endif @@ -158,8 +158,8 @@ namespace libtorrent // If a ``pad_size_limit`` is specified (other than -1), any file larger than // the specified number of bytes will be preceeded by a pad file to align it // with the start of a piece. The pad_file_limit is ignored unless the - // ``optimize`` flag is passed. Typically it doesn't make sense to set this - // any lower than 4kiB. + // ``optimize_alignment`` flag is passed. Typically it doesn't make sense + // to set this any lower than 4kiB. // // The overload that takes a ``torrent_info`` object will make a verbatim // copy of its info dictionary (to preserve the info-hash). The copy of @@ -175,7 +175,8 @@ namespace libtorrent // eligible files are aligned to. The default is -1, which means the // piece size of the torrent. create_torrent(file_storage& fs, int piece_size = 0 - , int pad_file_limit = -1, int flags = optimize, int alignment = -1); + , int pad_file_limit = -1, int flags = optimize_alignment + , int alignment = -1); create_torrent(torrent_info const& ti); // internal @@ -302,7 +303,7 @@ namespace libtorrent private: file_storage& m_files; - // if m_info_dict is initialized, it is + // if m_info_dict is initialized, it is // used instead of m_files to generate // the info dictionary entry m_info_dict; diff --git a/include/libtorrent/disk_interface.hpp b/include/libtorrent/disk_interface.hpp index 523f0f66a..a28c75a5d 100644 --- a/include/libtorrent/disk_interface.hpp +++ b/include/libtorrent/disk_interface.hpp @@ -71,6 +71,8 @@ namespace libtorrent , std::vector& links , boost::function const& handler) = 0; #ifndef TORRENT_NO_DEPRECATE + virtual void async_cache_piece(piece_manager* storage, int piece + , boost::function const& handler) = 0; virtual void async_finalize_file(piece_manager*, int file , boost::function const& handler = boost::function()) = 0; @@ -78,8 +80,6 @@ namespace libtorrent virtual void async_flush_piece(piece_manager* storage, int piece , boost::function const& handler = boost::function()) = 0; - virtual void async_cache_piece(piece_manager* storage, int piece - , boost::function const& handler) = 0; virtual void async_stop_torrent(piece_manager* storage , boost::function const& handler)= 0; virtual void async_rename_file(piece_manager* storage, int index, std::string const& name diff --git a/include/libtorrent/disk_io_job.hpp b/include/libtorrent/disk_io_job.hpp index e64c5d889..25bbdc485 100644 --- a/include/libtorrent/disk_io_job.hpp +++ b/include/libtorrent/disk_io_job.hpp @@ -92,8 +92,8 @@ namespace libtorrent , save_resume_data , rename_file , stop_torrent - , cache_piece #ifndef TORRENT_NO_DEPRECATE + , cache_piece , finalize_file #endif , flush_piece diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index da302f9c9..1d093efd0 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -323,9 +323,9 @@ namespace libtorrent , boost::function const& handler); void async_stop_torrent(piece_manager* storage , boost::function const& handler); +#ifndef TORRENT_NO_DEPRECATE void async_cache_piece(piece_manager* storage, int piece , boost::function const& handler); -#ifndef TORRENT_NO_DEPRECATE void async_finalize_file(piece_manager* storage, int file , boost::function const& handler = boost::function()); @@ -417,8 +417,8 @@ namespace libtorrent int do_rename_file(disk_io_job* j, jobqueue_t& completed_jobs); int do_stop_torrent(disk_io_job* j, jobqueue_t& completed_jobs); int do_read_and_hash(disk_io_job* j, jobqueue_t& completed_jobs); - int do_cache_piece(disk_io_job* j, jobqueue_t& completed_jobs); #ifndef TORRENT_NO_DEPRECATE + int do_cache_piece(disk_io_job* j, jobqueue_t& completed_jobs); int do_finalize_file(disk_io_job* j, jobqueue_t& completed_jobs); #endif int do_flush_piece(disk_io_job* j, jobqueue_t& completed_jobs); diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 2a7f6af7d..456eaee4f 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -264,7 +264,7 @@ namespace libtorrent // reading blocks back from the disk multiple times for popular // pieces. use_read_cache, -#ifndef TORRENT_NO_DEPRECATED +#ifndef TORRENT_NO_DEPRECATE use_write_cache, #else deprecated7, @@ -275,7 +275,7 @@ namespace libtorrent // hash dont_flush_write_cache, -#ifndef TORRENT_NO_DEPRECATED +#ifndef TORRENT_NO_DEPRECATE // ``explicit_read_cache`` defaults to 0. If set to something greater // than 0, the disk read cache will not be evicted by cache misses and // will explicitly be controlled based on the rarity of pieces. Rare @@ -928,7 +928,7 @@ namespace libtorrent cache_buffer_chunk_size, cache_expiry, -#ifndef TORRENT_NO_DEPRECATED +#ifndef TORRENT_NO_DEPRECATE // ``explicit_cache_interval`` is the number of seconds in between // each refresh of a part of the explicit read cache. Torrents take // turns in refreshing and this is the time in between each torrent diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index c9f418d31..fee3e2273 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -676,7 +676,7 @@ namespace libtorrent void get_peer_info(std::vector& v); void get_download_queue(std::vector* queue) const; -#ifndef TORRENT_NO_DEPRECATED +#ifndef TORRENT_NO_DEPRECATE void refresh_explicit_cache(int cache_size); #endif diff --git a/src/block_cache.cpp b/src/block_cache.cpp index 03141a5d3..2c0ba7d06 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -203,8 +203,8 @@ const char* const job_action_name[] = "save_resume_data", "rename_file", "stop_torrent", - "cache_piece", #ifndef TORRENT_NO_DEPRECATE + "cache_piece", "finalize_file", #endif "flush_piece", @@ -218,6 +218,12 @@ const char* const job_action_name[] = "resolve_links" }; +#if __cplusplus >= 201103L +// make sure the job names array covers all the job IDs +static_assert(sizeof(job_action_name)/sizeof(job_action_name[0]) + == disk_io_job::num_job_ids, "disk-job-action and action-name-array mismatch"); +#endif + #if TORRENT_USE_ASSERTS char const* const piece_log_t::job_names[7] = @@ -359,9 +365,6 @@ block_cache::block_cache(int block_size, io_service& ios , m_send_buffer_blocks(0) , m_pinned_blocks(0) { - // make sure the job names array covers all the job IDs - TORRENT_ASSERT(sizeof(job_action_name)/sizeof(job_action_name[0]) - == disk_io_job::num_job_ids); } // returns: diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 62f5fa1a5..10ae2c7fd 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -1040,8 +1040,8 @@ namespace libtorrent &disk_io_thread::do_save_resume_data, &disk_io_thread::do_rename_file, &disk_io_thread::do_stop_torrent, - &disk_io_thread::do_cache_piece, #ifndef TORRENT_NO_DEPRECATE + &disk_io_thread::do_cache_piece, &disk_io_thread::do_finalize_file, #endif &disk_io_thread::do_flush_piece, @@ -1951,6 +1951,7 @@ namespace libtorrent add_completed_jobs(completed_jobs); } +#ifndef TORRENT_NO_DEPRECATE void disk_io_thread::async_cache_piece(piece_manager* storage, int piece , boost::function const& handler) { @@ -1968,7 +1969,6 @@ namespace libtorrent add_job(j); } -#ifndef TORRENT_NO_DEPRECATE void disk_io_thread::async_finalize_file(piece_manager* storage, int file , boost::function const& handler) { @@ -1985,7 +1985,7 @@ namespace libtorrent add_job(j); } -#endif +#endif // TORRENT_NO_DEPRECATE void disk_io_thread::async_flush_piece(piece_manager* storage, int piece , boost::function const& handler) @@ -2618,6 +2618,7 @@ namespace libtorrent return j->error ? -1 : 0; } +#ifndef TORRENT_NO_DEPRECATE int disk_io_thread::do_cache_piece(disk_io_job* j, jobqueue_t& /* completed_jobs */ ) { INVARIANT_CHECK; @@ -2719,13 +2720,12 @@ namespace libtorrent return 0; } -#ifndef TORRENT_NO_DEPRECATE int disk_io_thread::do_finalize_file(disk_io_job* j, jobqueue_t& /* completed_jobs */) { j->storage->get_storage_impl()->finalize_file(j->piece, j->error); return j->error ? -1 : 0; } -#endif +#endif // TORRENT_NO_DEPRECATE namespace { diff --git a/src/session_handle.cpp b/src/session_handle.cpp index f6d656f70..08f437fb6 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -1013,7 +1013,7 @@ namespace libtorrent p.set_bool(settings_pack::enable_natpmp, false); apply_settings(p); } -#endif // TORRENT_NO_DEPRECATED +#endif // TORRENT_NO_DEPRECATE int session_handle::add_port_mapping(session::protocol_type t, int external_port, int local_port) { diff --git a/src/session_impl.cpp b/src/session_impl.cpp index d5dc33629..885e85216 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -393,7 +393,7 @@ namespace aux { , m_optimistic_unchoke_time_scaler(0) , m_disconnect_time_scaler(90) , m_auto_scrape_time_scaler(180) -#ifndef TORRENT_NO_DEPRECATED +#ifndef TORRENT_NO_DEPRECATE , m_next_explicit_cache_torrent(0) , m_cache_rotation_timer(0) #endif @@ -3335,7 +3335,7 @@ retry: ++m_next_suggest_torrent; } -#ifndef TORRENT_NO_DEPRECATED +#ifndef TORRENT_NO_DEPRECATE // -------------------------------------------------------------- // refresh explicit disk read cache // -------------------------------------------------------------- diff --git a/src/torrent.cpp b/src/torrent.cpp index ced7edf54..04226a615 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -10576,7 +10576,7 @@ namespace libtorrent update_want_peers(); } -#ifndef TORRENT_NO_DEPRECATED +#ifndef TORRENT_NO_DEPRECATE // TODO: 2 this should probably be removed void torrent::refresh_explicit_cache(int cache_size) { @@ -10675,7 +10675,7 @@ namespace libtorrent } } } -#endif +#endif // TORRENT_NO_DEPRECATE void torrent::sent_bytes(int bytes_payload, int bytes_protocol) { diff --git a/test/test_checking.cpp b/test/test_checking.cpp index f78f3b04b..f489c05b6 100644 --- a/test/test_checking.cpp +++ b/test/test_checking.cpp @@ -103,7 +103,8 @@ void test_checking(int flags = read_only_files) , file_sizes, num_files); add_files(fs, combine_path("tmp1_checking", "test_torrent_dir")); - libtorrent::create_torrent t(fs, piece_size, 0x4000, libtorrent::create_torrent::optimize); + libtorrent::create_torrent t(fs, piece_size, 0x4000 + , libtorrent::create_torrent::optimize_alignment); // calculate the hash for all pieces set_piece_hashes(t, "tmp1_checking", ec); diff --git a/test/test_remap_files.cpp b/test/test_remap_files.cpp index ee6f2c0de..e7eed2238 100644 --- a/test/test_remap_files.cpp +++ b/test/test_remap_files.cpp @@ -410,7 +410,7 @@ void test_remap_files_prio(storage_mode_t storage_mode = storage_mode_sparse) add_files(fs1, combine_path("tmp1_remap3", "test_torrent_dir")); libtorrent::create_torrent ct(fs1, piece_size, 0x4000 - , libtorrent::create_torrent::optimize); + , libtorrent::create_torrent::optimize_alignment); // calculate the hash for all pieces set_piece_hashes(ct, "tmp1_remap3", ec);