diff --git a/include/libtorrent/aux_/block_cache_reference.hpp b/include/libtorrent/aux_/block_cache_reference.hpp index 5314207fd..ebf79571b 100644 --- a/include/libtorrent/aux_/block_cache_reference.hpp +++ b/include/libtorrent/aux_/block_cache_reference.hpp @@ -36,21 +36,19 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/units.hpp" #include "libtorrent/storage_defs.hpp" -namespace libtorrent { -namespace aux { +namespace libtorrent { namespace aux { struct block_cache_reference { - storage_index_t storage; - std::uint32_t cookie; - // if the cookie is set to this value, it doesn't refer to anything in the // cache (and the buffer is mutable) static std::uint32_t const none = 0xffffffffu; + + storage_index_t storage{0}; + std::uint32_t cookie = none; }; -} -} +}} #endif diff --git a/include/libtorrent/disk_io_job.hpp b/include/libtorrent/disk_io_job.hpp index 127d5ec27..e75677d5f 100644 --- a/include/libtorrent/disk_io_job.hpp +++ b/include/libtorrent/disk_io_job.hpp @@ -170,8 +170,9 @@ namespace libtorrent // file the disk operation failed on storage_error error; - union + union un { + un() {} // result for hash jobs char piece_hash[20]; diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 7dbf411db..f7148b62e 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -361,8 +361,6 @@ namespace libtorrent virtual file_pool& files() override { return m_file_pool; } - io_service& get_io_service() { return m_ios; } - int prep_read_job_impl(disk_io_job* j, bool check_fence = true); void maybe_issue_queued_read_jobs(cached_piece_entry* pe, @@ -561,9 +559,6 @@ namespace libtorrent // the main thread. io_service& m_ios; - // used to rate limit disk performance warnings - time_point m_last_disk_aio_performance_warning = min_time(); - // jobs that are completed are put on this queue // whenever the queue size grows from 0 to 1 // a message is posted to the network thread, which diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 43e3fcdc0..f4242a566 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -98,6 +98,9 @@ namespace libtorrent struct session_impl; } + struct disk_interface; + struct counters; + // this is a holder for the internal session implementation object. Once the // session destruction is explicitly initiated, this holder is used to // synchronize the completion of the shutdown. The lifetime of this object diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index b1328c212..f89be6859 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -41,6 +41,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert.hpp" // alert::error_notification #include "libtorrent/peer_class.hpp" #include "libtorrent/peer_class_type_filter.hpp" +#include "libtorrent/peer_id.hpp" +#include "libtorrent/io_service.hpp" #include "libtorrent/kademlia/dht_storage.hpp" @@ -57,6 +59,7 @@ namespace libtorrent struct ip_filter; class port_filter; class alert; + struct settings_pack; #ifndef TORRENT_NO_DEPRECATE struct session_status; diff --git a/simulation/create_torrent.cpp b/simulation/create_torrent.cpp index 471022944..e33632b4d 100644 --- a/simulation/create_torrent.cpp +++ b/simulation/create_torrent.cpp @@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" // for ::create_torrent #include "libtorrent/add_torrent_params.hpp" +#include "libtorrent/file.hpp" #include namespace lt = libtorrent; diff --git a/simulation/setup_dht.cpp b/simulation/setup_dht.cpp index b4281a537..060bfe850 100644 --- a/simulation/setup_dht.cpp +++ b/simulation/setup_dht.cpp @@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/random.hpp" #include "libtorrent/crc32c.hpp" #include "libtorrent/alert_types.hpp" // for dht_routing_bucket +#include "libtorrent/file.hpp" #include "setup_dht.hpp" diff --git a/simulation/setup_swarm.cpp b/simulation/setup_swarm.cpp index 3c6123ab9..f66165f48 100644 --- a/simulation/setup_swarm.cpp +++ b/simulation/setup_swarm.cpp @@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/settings_pack.hpp" #include "libtorrent/ip_filter.hpp" #include "libtorrent/alert_types.hpp" +#include "libtorrent/file.hpp" #include #include "settings.hpp" diff --git a/src/disk_buffer_holder.cpp b/src/disk_buffer_holder.cpp index 183498c48..eff9be279 100644 --- a/src/disk_buffer_holder.cpp +++ b/src/disk_buffer_holder.cpp @@ -39,10 +39,7 @@ namespace libtorrent disk_buffer_holder::disk_buffer_holder(buffer_allocator_interface& alloc, char* buf) noexcept : m_allocator(&alloc), m_buf(buf) - { - m_ref.storage = storage_index_t{0}; - m_ref.cookie = aux::block_cache_reference::none; - } + {} disk_buffer_holder& disk_buffer_holder::operator=(disk_buffer_holder&& h) noexcept { @@ -75,14 +72,14 @@ namespace libtorrent if (m_ref.cookie != aux::block_cache_reference::none) m_allocator->reclaim_blocks(m_ref); else if (m_buf) m_allocator->free_disk_buffer(m_buf); m_buf = buf; - m_ref.cookie = aux::block_cache_reference::none; + m_ref = aux::block_cache_reference(); } char* disk_buffer_holder::release() noexcept { char* ret = m_buf; m_buf = nullptr; - m_ref.cookie = aux::block_cache_reference::none; + m_ref = aux::block_cache_reference(); return ret; } diff --git a/src/disk_io_job.cpp b/src/disk_io_job.cpp index b7b2b4065..f2fff85b2 100644 --- a/src/disk_io_job.cpp +++ b/src/disk_io_job.cpp @@ -105,7 +105,6 @@ namespace libtorrent buffer.disk_block = nullptr; d.io.offset = 0; d.io.buffer_size = 0; - d.io.ref.storage = storage_index_t{0}; d.io.ref.cookie = aux::block_cache_reference::none; } diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 3910e3eb4..d4ce229a4 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert_manager.hpp" #include "libtorrent/debug.hpp" #include "libtorrent/units.hpp" +#include "libtorrent/hasher.hpp" #include @@ -331,7 +332,7 @@ namespace libtorrent if (end == 0 && !p->need_readback) return 0; // the number of contiguous blocks we need to be allowed to flush - int block_limit = (std::min)(cont_block, int(p->blocks_in_piece)); + int block_limit = std::min(cont_block, int(p->blocks_in_piece)); // if everything has been hashed, we might as well flush everything // regardless of the contiguous block restriction diff --git a/test/swarm_suite.cpp b/test/swarm_suite.cpp index 877e8a293..7efd63dd8 100644 --- a/test/swarm_suite.cpp +++ b/test/swarm_suite.cpp @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert_types.hpp" #include "libtorrent/time.hpp" #include "libtorrent/random.hpp" +#include "libtorrent/file.hpp" #include #include diff --git a/test/test_auto_unchoke.cpp b/test/test_auto_unchoke.cpp index 82e63788d..d72b233cc 100644 --- a/test/test_auto_unchoke.cpp +++ b/test/test_auto_unchoke.cpp @@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hasher.hpp" #include "libtorrent/alert_types.hpp" #include "libtorrent/ip_filter.hpp" +#include "libtorrent/file.hpp" #include #include diff --git a/test/test_dht.cpp b/test/test_dht.cpp index 54704d1d2..a2bccb336 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -47,6 +47,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/ed25519.hpp" #include "libtorrent/hex.hpp" // to_hex, from_hex #include "libtorrent/bloom_filter.hpp" +#include "libtorrent/hasher.hpp" +#include "libtorrent/aux_/time.hpp" #include "libtorrent/kademlia/node_id.hpp" #include "libtorrent/kademlia/routing_table.hpp" diff --git a/test/test_direct_dht.cpp b/test/test_direct_dht.cpp index 5d1edb43c..6f0f410e9 100644 --- a/test/test_direct_dht.cpp +++ b/test/test_direct_dht.cpp @@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/session.hpp" #include "libtorrent/extensions.hpp" #include "libtorrent/alert_types.hpp" +#include "libtorrent/bdecode.hpp" using namespace libtorrent; namespace lt = libtorrent; diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index 72f1bc27e..4c44a15a9 100644 --- a/test/test_fast_extension.cpp +++ b/test/test_fast_extension.cpp @@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bencode.hpp" #include "libtorrent/entry.hpp" #include "libtorrent/torrent_info.hpp" +#include "libtorrent/file.hpp" #include #include diff --git a/test/test_http_connection.cpp b/test/test_http_connection.cpp index f7a5d18e0..f79a78b1f 100644 --- a/test/test_http_connection.cpp +++ b/test/test_http_connection.cpp @@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket_io.hpp" // print_endpoint #include "libtorrent/http_connection.hpp" #include "libtorrent/resolver.hpp" +#include "libtorrent/file.hpp" #include #include diff --git a/test/test_lsd.cpp b/test/test_lsd.cpp index 6556bbd69..446973e74 100644 --- a/test/test_lsd.cpp +++ b/test/test_lsd.cpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/session_settings.hpp" #include "libtorrent/torrent_status.hpp" #include "libtorrent/hasher.hpp" +#include "libtorrent/file.hpp" #include #include "test.hpp" diff --git a/test/test_pex.cpp b/test/test_pex.cpp index 6058e40cf..a4eeafb92 100644 --- a/test/test_pex.cpp +++ b/test/test_pex.cpp @@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/extensions/ut_pex.hpp" #include "libtorrent/ip_filter.hpp" #include "libtorrent/torrent_status.hpp" +#include "libtorrent/file.hpp" #include #include "setup_transfer.hpp" diff --git a/test/test_privacy.cpp b/test/test_privacy.cpp index 765ddcfdf..eb637ead5 100644 --- a/test/test_privacy.cpp +++ b/test/test_privacy.cpp @@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/random.hpp" #include "libtorrent/alert_types.hpp" #include "libtorrent/torrent_info.hpp" +#include "libtorrent/file.hpp" #include diff --git a/test/test_session.cpp b/test/test_session.cpp index 46a211937..d391eac6e 100644 --- a/test/test_session.cpp +++ b/test/test_session.cpp @@ -56,13 +56,12 @@ TORRENT_TEST(session) lt::session ses(p); settings_pack sett = settings(); - sett.set_int(settings_pack::cache_size, 100); - sett.set_int(settings_pack::max_queued_disk_bytes, 1000 * 16 * 1024); + sett.set_int(settings_pack::num_optimistic_unchoke_slots, 10); + sett.set_int(settings_pack::unchoke_slots_limit, 10); ses.apply_settings(sett); - // verify that we get the appropriate performance warning because - // we're allowing a larger queue than we have cache. + // verify that we get the appropriate performance warning alert const* a; for (;;) @@ -73,7 +72,7 @@ TORRENT_TEST(session) TEST_EQUAL(a->type(), performance_alert::alert_type); if (alert_cast(a)->warning_code - == performance_alert::too_high_disk_queue_limit) + == performance_alert::too_many_optimistic_unchoke_slots) break; } @@ -239,19 +238,19 @@ TORRENT_TEST(save_restore_state) test_save_restore( [](settings_pack& p) { // set the cache size - p.set_int(settings_pack::cache_size, 1337); + p.set_int(settings_pack::request_queue_time, 1337); }, [](lt::session& ses, entry& st) { ses.save_state(st); }, [](settings_pack& p) { - p.set_int(settings_pack::cache_size, 90); + p.set_int(settings_pack::request_queue_time, 90); }, [](lt::session& ses, bdecode_node& st) { ses.load_state(st); // make sure we loaded the cache size correctly settings_pack sett = ses.get_settings(); - TEST_EQUAL(sett.get_int(settings_pack::cache_size), 1337); + TEST_EQUAL(sett.get_int(settings_pack::request_queue_time), 1337); }); } @@ -260,20 +259,20 @@ TORRENT_TEST(save_restore_state_save_filter) test_save_restore( [](settings_pack& p) { // set the cache size - p.set_int(settings_pack::cache_size, 1337); + p.set_int(settings_pack::request_queue_time, 1337); }, [](lt::session& ses, entry& st) { // save everything _but_ the settings ses.save_state(st, ~session::save_settings); }, [](settings_pack& p) { - p.set_int(settings_pack::cache_size, 90); + p.set_int(settings_pack::request_queue_time, 90); }, [](lt::session& ses, bdecode_node& st) { ses.load_state(st); // make sure whatever we loaded did not include the cache size settings_pack sett = ses.get_settings(); - TEST_EQUAL(sett.get_int(settings_pack::cache_size), 90); + TEST_EQUAL(sett.get_int(settings_pack::request_queue_time), 90); }); } @@ -282,20 +281,20 @@ TORRENT_TEST(save_restore_state_load_filter) test_save_restore( [](settings_pack& p) { // set the cache size - p.set_int(settings_pack::cache_size, 1337); + p.set_int(settings_pack::request_queue_time, 1337); }, [](lt::session& ses, entry& st) { // save everything ses.save_state(st); }, [](settings_pack& p) { - p.set_int(settings_pack::cache_size, 90); + p.set_int(settings_pack::request_queue_time, 90); }, [](lt::session& ses, bdecode_node& st) { // load everything _but_ the settings ses.load_state(st, ~session::save_settings); settings_pack sett = ses.get_settings(); - TEST_EQUAL(sett.get_int(settings_pack::cache_size), 90); + TEST_EQUAL(sett.get_int(settings_pack::request_queue_time), 90); }); } diff --git a/test/test_tracker.cpp b/test/test_tracker.cpp index df4f8398c..2b2251bda 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -45,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_info.hpp" #include "libtorrent/announce_entry.hpp" #include "libtorrent/torrent.hpp" +#include "libtorrent/file.hpp" #include diff --git a/test/test_upnp.cpp b/test/test_upnp.cpp index a1d76ac55..bbaef861a 100644 --- a/test/test_upnp.cpp +++ b/test/test_upnp.cpp @@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket_io.hpp" // print_endpoint #include "test.hpp" #include "setup_transfer.hpp" +#include "libtorrent/file.hpp" #include #include #include