forked from premiere/premiere-libtorrent
parent
41dbb47123
commit
57f52adc88
|
@ -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
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 <fstream>
|
||||
|
||||
namespace lt = libtorrent;
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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 <fstream>
|
||||
|
||||
#include "settings.hpp"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <functional>
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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 <iostream>
|
||||
#include <tuple>
|
||||
|
||||
|
|
|
@ -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 <tuple>
|
||||
#include <iostream>
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 <cstring>
|
||||
#include <functional>
|
||||
|
|
|
@ -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 <fstream>
|
||||
#include <iostream>
|
||||
|
|
|
@ -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 <tuple>
|
||||
|
||||
#include "test.hpp"
|
||||
|
|
|
@ -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 <tuple>
|
||||
|
||||
#include "setup_transfer.hpp"
|
||||
|
|
|
@ -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 <fstream>
|
||||
|
||||
|
|
|
@ -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<performance_alert>(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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <fstream>
|
||||
|
||||
|
|
|
@ -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 <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
|
|
Loading…
Reference in New Issue