merge RC_1_1 into master

This commit is contained in:
arvidn 2016-03-30 00:28:57 -04:00
commit fd4a46342f
26 changed files with 110 additions and 199 deletions

View File

@ -129,8 +129,7 @@ enum proxy_type_t
enum storage_mode_t
{
storage_mode_allocate = 0,
storage_mode_sparse,
storage_mode_compact
storage_mode_sparse
};
enum state_t
@ -144,7 +143,7 @@ enum state_t
allocating,
checking_resume_data
};
struct torrent_status
{
enum state_t state;

View File

@ -168,9 +168,6 @@ def main():
parser.add_option('-s', '--save-path',
type='string', help='the path where the downloaded file/folder should be placed.')
parser.add_option('-a', '--allocation-mode',
type='string', help='sets mode used for allocating the downloaded files on disk. Possible options are [full | compact]')
parser.add_option('-r', '--proxy-host',
type='string', help='sets HTTP proxy host and port (separated by \':\')')
@ -179,7 +176,6 @@ def main():
, max_download_rate=0
, max_upload_rate=0
, save_path='.'
, allocation_mode='compact'
, proxy_host=''
)
@ -196,8 +192,6 @@ def main():
if options.max_download_rate <= 0:
options.max_download_rate = -1
compact_allocation = options.allocation_mode == 'compact'
settings = lt.session_settings()
settings.user_agent = 'python_client/' + lt.version

View File

@ -655,9 +655,6 @@ void bind_session()
enum_<storage_mode_t>("storage_mode_t")
.value("storage_mode_allocate", storage_mode_allocate)
.value("storage_mode_sparse", storage_mode_sparse)
#ifndef TORRENT_NO_DEPRECATE
.value("storage_mode_compact", storage_mode_compact)
#endif
;
enum_<lt::session::options_t>("options_t")

View File

@ -506,16 +506,6 @@ There are two modes in which storage (files on disk) are allocated in libtorrent
2. The *sparse allocation*, sparse files are used, and pieces are downloaded
directly to where they belong. This is the recommended (and default) mode.
In previous versions of libtorrent, a 3rd mode was supported, *compact
allocation*. Support for this is deprecated and will be removed in future
versions of libtorrent. It's still described in here for completeness.
The allocation mode is selected when a torrent is started. It is passed as an
argument to session::add_torrent() or session::async_add_torrent().
The decision to use full allocation or compact allocation typically depends on
whether any files have priority 0 and if the filesystem supports sparse files.
sparse allocation
-----------------

View File

@ -694,6 +694,10 @@ namespace libtorrent
private:
// return the settings value for int setting "n", if the value is
// negative, return INT_MAX
int get_int_setting(int n) const;
std::vector<torrent*> m_torrent_lists[num_torrent_lists];
peer_class_pool m_classes;

View File

@ -365,7 +365,7 @@ namespace libtorrent
// The 'blocks per piece' entry is invalid in the resume data file
invalid_blocks_per_piece,
// The resume file is missing the 'slots' entry, which is required
// for torrents with compact allocation
// for torrents with compact allocation. *DEPRECATED*
missing_slots,
// The resume file contains more slots than the torrent
too_many_slots,
@ -376,7 +376,7 @@ namespace libtorrent
// The pieces on disk needs to be re-ordered for the specified
// allocation mode. This happens if you specify sparse allocation
// and the files on disk are using compact storage. The pieces needs
// to be moved to their right position
// to be moved to their right position. *DEPRECATED*
pieces_need_reorder,
// this error is returned when asking to save resume data and
// specifying the flag to only save when there's anything new to save

View File

@ -719,8 +719,6 @@ namespace libtorrent
// start downloading payload again
void on_disk();
void on_allocate_disk_buffer(char* buffer, int buffer_size);
int num_reading_bytes() const { return m_reading_bytes; }
enum sync_t { read_async, read_sync };

View File

@ -153,17 +153,6 @@ namespace libtorrent
struct cached_piece_entry;
struct add_torrent_params;
TORRENT_EXTRA_EXPORT std::vector<std::pair<boost::int64_t, std::time_t> > get_filesizes(
file_storage const& t
, std::string const& p);
TORRENT_EXTRA_EXPORT bool match_filesizes(
file_storage const& t
, std::string const& p
, std::vector<std::pair<boost::int64_t, std::time_t> > const& sizes
, bool compact_mode
, std::string* error = 0);
TORRENT_EXTRA_EXPORT int copy_bufs(file::iovec_t const* bufs, int bytes, file::iovec_t* target);
TORRENT_EXTRA_EXPORT void advance_bufs(file::iovec_t*& bufs, int bytes);
TORRENT_EXTRA_EXPORT void clear_bufs(file::iovec_t const* bufs, int num_bufs);

View File

@ -55,14 +55,7 @@ namespace libtorrent
// All pieces will be written to the place where they belong and sparse files
// will be used. This is the recommended, and default mode.
storage_mode_sparse,
// internal
internal_storage_mode_compact_deprecated
#ifndef TORRENT_NO_DEPRECATE
, // comma here to avoid compiler warning
storage_mode_compact = internal_storage_mode_compact_deprecated
#endif
storage_mode_sparse
};
// see default_storage::default_storage()
@ -78,7 +71,7 @@ namespace libtorrent
std::vector<boost::uint8_t> const* priorities; // optional
torrent_info const* info; // optional
};
typedef boost::function<storage_interface*(storage_params const& params)> storage_constructor_type;
// the constructor function for the regular file storage. This is the

@ -1 +1 @@
Subproject commit 277389e87cfddd1747da7a8c7287e52ef592d345
Subproject commit 66356b0ce99cd126c7c99df50609b3050ba44e5d

View File

@ -46,6 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "settings.hpp"
#include "setup_swarm.hpp"
#include "setup_transfer.hpp" // for create_torrent
#include "utils.hpp"
namespace lt = libtorrent;
using namespace sim;
@ -104,11 +105,6 @@ std::string save_path(int swarm_id, int idx)
return path;
}
lt::address addr(char const* str)
{
return lt::address::from_string(str);
}
void add_extra_peers(lt::session& ses)
{
auto handles = ses.get_torrents();

View File

@ -95,9 +95,6 @@ lt::torrent_status get_status(lt::session& ses);
std::string save_path(int swarm_id, int idx);
// construct an address from string
lt::address addr(char const* str);
// disable TCP and enable uTP
void utp_only(lt::settings_pack& pack);

View File

@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "settings.hpp"
#include "create_torrent.hpp"
#include "simulator/simulator.hpp"
#include "simulator/utils.hpp"
#include <iostream>
using namespace sim;
@ -80,9 +81,8 @@ void run_test(Settings const& sett, Setup const& setup, Test const& test)
// set up a timer to fire later, to verify everything we expected to happen
// happened
lt::deadline_timer timer(*ios);
timer.expires_from_now(lt::seconds((num_torrents + 1) * 60));
timer.async_wait([&](boost::system::error_code const& ec)
sim::timer t(sim, lt::seconds((num_torrents + 1) * 60)
, [&](boost::system::error_code const& ec)
{
test(*ses);

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/address.hpp"
#include "libtorrent/torrent_status.hpp"
#include "simulator/simulator.hpp"
#include "simulator/utils.hpp"
#include "test.hpp"
#include "settings.hpp"
@ -63,9 +64,7 @@ void run_test(Setup const& setup, Test const& test)
print_alerts(*ses);
lt::deadline_timer timer(*ios);
timer.expires_from_now(lt::seconds(6));
timer.async_wait([&](lt::error_code const& ec)
sim::timer t(sim, lt::seconds(6), [&](boost::system::error_code const& ec)
{
test(*ses);

View File

@ -40,6 +40,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/ip_filter.hpp"
#include "libtorrent/alert_types.hpp"
#include "simulator/simulator.hpp"
#include "simulator/utils.hpp"
#include "utils.hpp" // for print_alerts
using namespace sim;
@ -85,8 +87,6 @@ void run_test(Setup const& setup
, HandleAlerts const& on_alert
, Test const& test)
{
const lt::time_point start_time = lt::clock_type::now();
// setup the simulation
sim::default_config network_cfg;
sim::simulation sim{network_cfg};
@ -114,22 +114,11 @@ void run_test(Setup const& setup
// the alert notification function is called from within libtorrent's
// context. It's not OK to talk to libtorrent in there, post it back out and
// then ask for alerts.
ses->set_alert_notify([&] { ios.post([&] {
std::vector<lt::alert*> alerts;
ses->pop_alerts(&alerts);
// call the user handler
for (auto const a : alerts)
{
printf("%-3d %s\n", int(lt::duration_cast<lt::seconds>(a->timestamp()
- start_time).count()), a->message().c_str());
print_alerts(*ses, [=](lt::session& ses, lt::alert const* a) {
on_alert(ses, a);
});
on_alert(*ses, a);
}
} ); } );
lt::deadline_timer timer(ios);
timer.expires_from_now(lt::seconds(60));
timer.async_wait([&](lt::error_code const& ec)
sim::timer t(sim, lt::seconds(60), [&](boost::system::error_code const& ec)
{
test(*ses, test_peers);

View File

@ -35,7 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "create_torrent.hpp"
#include "bittorrent_peer.hpp"
#include "settings.hpp"
#include "print_alerts.hpp"
#include "utils.hpp"
#include "simulator/utils.hpp"
#include "libtorrent/alert.hpp"
#include "libtorrent/alert_types.hpp"
@ -61,7 +62,8 @@ struct choke_state
TORRENT_TEST(optimistic_unchoke)
{
int const num_nodes = 20;
lt::time_duration const test_duration = libtorrent::seconds(1201);
lt::time_duration const test_duration
= libtorrent::seconds(num_nodes * 90);
dsl_config network_cfg;
sim::simulation sim{network_cfg};
@ -82,31 +84,24 @@ TORRENT_TEST(optimistic_unchoke)
session_proxy proxy;
boost::shared_ptr<lt::session> ses = boost::make_shared<lt::session>(
boost::ref(pack), boost::ref(ios));
auto ses = std::make_shared<lt::session>(std::ref(pack), std::ref(ios));
ses->async_add_torrent(atp);
std::vector<boost::shared_ptr<sim::asio::io_service> > io_service;
std::vector<boost::shared_ptr<peer_conn> > peers;
std::vector<std::shared_ptr<sim::asio::io_service> > io_service;
std::vector<std::shared_ptr<peer_conn> > peers;
ses->set_alert_notify([&]() {
// this function is called inside libtorrent and we cannot perform work
// immediately in it. We have to notify the outside to pull all the alerts
ios.post(boost::bind(&print_alerts, ses.get(), start_time));
});
print_alerts(*ses);
lt::deadline_timer timer(ios);
timer.expires_from_now(libtorrent::seconds(2));
timer.async_wait([&](error_code const& ec)
sim::timer t(sim, lt::seconds(0), [&](boost::system::error_code const& ec)
{
for (int i = 0; i < num_nodes; ++i)
{
// create a new io_service
char ep[30];
snprintf(ep, sizeof(ep), "50.0.%d.%d", (i + 1) >> 8, (i + 1) & 0xff);
io_service.push_back(boost::make_shared<sim::asio::io_service>(
boost::ref(sim), addr(ep)));
peers.push_back(boost::make_shared<peer_conn>(boost::ref(*io_service.back())
io_service.push_back(std::make_shared<sim::asio::io_service>(
std::ref(sim), addr(ep)));
peers.push_back(std::make_shared<peer_conn>(std::ref(*io_service.back())
, [&,i](int msg, char const* bug, int len)
{
choke_state& cs = peer_choke_state[i];
@ -136,7 +131,7 @@ TORRENT_TEST(optimistic_unchoke)
char const* msg_str[] = {"choke", "unchoke"};
lt::time_duration d = lt::clock_type::now() - start_time;
boost::uint32_t millis = lt::duration_cast<lt::milliseconds>(d).count();
std::uint32_t millis = lt::duration_cast<lt::milliseconds>(d).count();
printf("\x1b[35m%4d.%03d: [%d] %s (%d ms)\x1b[0m\n"
, millis / 1000, millis % 1000, i, msg_str[msg]
, int(lt::duration_cast<lt::milliseconds>(cs.unchoke_duration).count()));
@ -147,28 +142,32 @@ TORRENT_TEST(optimistic_unchoke)
}
});
lt::deadline_timer end_timer(ios);
timer.expires_from_now(test_duration);
timer.async_wait([&](error_code const& ec)
sim::timer t2(sim, test_duration, [&](boost::system::error_code const& ec)
{
for (auto& p : peers)
{
p->abort();
}
ses->set_alert_notify([]{});
proxy = ses->abort();
ses.reset();
});
sim.run();
boost::int64_t const duration_ms = lt::duration_cast<lt::milliseconds>(test_duration).count();
boost::int64_t const average_unchoke_time = duration_ms / num_nodes;
std::int64_t const duration_ms = lt::duration_cast<lt::milliseconds>(test_duration).count();
std::int64_t const average_unchoke_time = duration_ms / num_nodes;
printf("EXPECT: %" PRId64 " ms\n", average_unchoke_time);
for (auto const& cs : peer_choke_state)
for (auto& cs : peer_choke_state)
{
boost::int64_t unchoke_duration = lt::duration_cast<lt::milliseconds>(cs.unchoke_duration).count();
if (!cs.choked)
{
cs.choked = true;
cs.unchoke_duration += lt::clock_type::now() - cs.last_unchoke;
}
std::int64_t const unchoke_duration = lt::duration_cast<lt::milliseconds>(cs.unchoke_duration).count();
printf("%" PRId64 " ms\n", unchoke_duration);
TEST_CHECK(std::abs(unchoke_duration - average_unchoke_time) < 1000);
TEST_CHECK(std::abs(unchoke_duration - average_unchoke_time) < 1500);
}
}

View File

@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "setup_swarm.hpp"
#include "test.hpp"
#include "utils.hpp"
#include "libtorrent/alert.hpp"
#include "libtorrent/alert_types.hpp"
#include "libtorrent/session.hpp"

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "setup_swarm.hpp"
#include "simulator/simulator.hpp"
#include "simulator/http_server.hpp"
#include "simulator/utils.hpp"
#include "libtorrent/alert_types.hpp"
#include "libtorrent/announce_entry.hpp"
#include "libtorrent/session.hpp"
@ -323,7 +324,6 @@ TORRENT_TEST(ipv6_support)
ses->set_alert_notify(std::bind(&on_alert_notify, ses.get()));
lt::add_torrent_params p;
p.name = "test-torrent";
p.save_path = ".";
@ -334,9 +334,8 @@ TORRENT_TEST(ipv6_support)
ses->async_add_torrent(p);
// stop the torrent 5 seconds in
asio::high_resolution_timer stop(ios);
stop.expires_from_now(chrono::seconds(5));
stop.async_wait([&ses](boost::system::error_code const& ec)
sim::timer t1(sim, lt::seconds(5)
, [&ses](boost::system::error_code const& ec)
{
std::vector<lt::torrent_handle> torrents = ses->get_torrents();
for (auto const& t : torrents)
@ -346,9 +345,8 @@ TORRENT_TEST(ipv6_support)
});
// then shut down 10 seconds in
asio::high_resolution_timer terminate(ios);
terminate.expires_from_now(chrono::seconds(10));
terminate.async_wait([&ses,&zombie](boost::system::error_code const& ec)
sim::timer t2(sim, lt::seconds(10)
, [&ses,&zombie](boost::system::error_code const& ec)
{
zombie = ses->abort();
ses->set_alert_notify([]{});
@ -403,9 +401,8 @@ void tracker_test(Setup setup, Announce a, Test1 test1, Test2 test2
ses->async_add_torrent(p);
// run the test 5 seconds in
asio::high_resolution_timer t1(ios);
t1.expires_from_now(chrono::seconds(5));
t1.async_wait([&ses,&test1](boost::system::error_code const& ec)
sim::timer t1(sim, lt::seconds(5)
, [&ses,&test1](boost::system::error_code const& ec)
{
std::vector<lt::torrent_handle> torrents = ses->get_torrents();
TEST_EQUAL(torrents.size(), 1);
@ -413,9 +410,8 @@ void tracker_test(Setup setup, Announce a, Test1 test1, Test2 test2
test1(h);
});
asio::high_resolution_timer t2(ios);
t2.expires_from_now(chrono::seconds(5 + delay));
t2.async_wait([&ses,&test2](boost::system::error_code const& ec)
sim::timer t2(sim, lt::seconds(5 + delay)
, [&ses,&test2](boost::system::error_code const& ec)
{
std::vector<lt::torrent_handle> torrents = ses->get_torrents();
TEST_EQUAL(torrents.size(), 1);
@ -424,9 +420,8 @@ void tracker_test(Setup setup, Announce a, Test1 test1, Test2 test2
});
// then shut down 10 seconds in
asio::high_resolution_timer t3(ios);
t3.expires_from_now(chrono::seconds(10 + delay));
t3.async_wait([&ses,&zombie](boost::system::error_code const& ec)
sim::timer t3(sim, lt::seconds(10 + delay)
, [&ses,&zombie](boost::system::error_code const& ec)
{
zombie = ses->abort();
ses->set_alert_notify([]{});

View File

@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/settings_pack.hpp"
#include "simulator/simulator.hpp"
#include "simulator/socks_server.hpp"
#include "simulator/utils.hpp"
#include "setup_swarm.hpp"
#include "utils.hpp"
@ -128,9 +129,7 @@ void run_test(
params.save_path = save_path(1);
ses[1]->async_add_torrent(params);
lt::deadline_timer timer(ios0);
timer.expires_from_now(lt::seconds(60));
timer.async_wait([&](lt::error_code const& ec)
sim::timer t(sim, lt::seconds(60), [&](boost::system::error_code const& ec)
{
test(ses);

View File

@ -116,6 +116,11 @@ void set_proxy(lt::session& ses, int proxy_type, int flags, bool proxy_peer_conn
ses.apply_settings(p);
}
lt::address addr(char const* str)
{
return lt::address::from_string(str);
}
void print_alerts(lt::session& ses
, std::function<void(lt::session&, lt::alert const*)> on_alert)
{

View File

@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include <functional>
#include "libtorrent/address.hpp"
namespace libtorrent
{
@ -40,6 +41,9 @@ namespace libtorrent
namespace lt = libtorrent;
// construct an address from string
lt::address addr(char const* str);
void utp_only(lt::session& ses);
void enable_enc(lt::session& ses);
void filter_ips(lt::session& ses);

View File

@ -5701,21 +5701,6 @@ namespace libtorrent
setup_receive();
}
void peer_connection::on_allocate_disk_buffer(char* buffer, int buffer_size)
{
TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK;
TORRENT_ASSERT(m_channel_state[download_channel] & peer_info::bw_disk);
m_recv_buffer.assign_disk_buffer(buffer, buffer_size);
m_counters.inc_stats_counter(counters::num_peers_down_disk, -1);
m_channel_state[download_channel] &= ~peer_info::bw_disk;
setup_receive();
}
void peer_connection::setup_receive()
{
TORRENT_ASSERT(is_single_thread());

View File

@ -3699,6 +3699,13 @@ namespace aux {
}
}
int session_impl::get_int_setting(int n) const
{
int const v = settings().get_int(n);
if (v < 0) return (std::numeric_limits<int>::max)();
return v;
}
void session_impl::recalculate_auto_managed_torrents()
{
INVARIANT_CHECK;
@ -3719,28 +3726,13 @@ namespace aux {
// these counters are set to the number of torrents
// of each kind we're allowed to have active
int downloading_limit = settings().get_int(settings_pack::active_downloads);
int seeding_limit = settings().get_int(settings_pack::active_seeds);
int checking_limit = settings().get_int(settings_pack::active_checking);
int dht_limit = settings().get_int(settings_pack::active_dht_limit);
int tracker_limit = settings().get_int(settings_pack::active_tracker_limit);
int lsd_limit = settings().get_int(settings_pack::active_lsd_limit);
int hard_limit = settings().get_int(settings_pack::active_limit);
if (downloading_limit == -1)
downloading_limit = (std::numeric_limits<int>::max)();
if (seeding_limit == -1)
seeding_limit = (std::numeric_limits<int>::max)();
if (checking_limit == -1)
checking_limit = (std::numeric_limits<int>::max)();
if (hard_limit == -1)
hard_limit = (std::numeric_limits<int>::max)();
if (dht_limit == -1)
dht_limit = (std::numeric_limits<int>::max)();
if (lsd_limit == -1)
lsd_limit = (std::numeric_limits<int>::max)();
if (tracker_limit == -1)
tracker_limit = (std::numeric_limits<int>::max)();
int downloading_limit = get_int_setting(settings_pack::active_downloads);
int seeding_limit = get_int_setting(settings_pack::active_seeds);
int checking_limit = get_int_setting(settings_pack::active_checking);
int dht_limit = get_int_setting(settings_pack::active_dht_limit);
int tracker_limit = get_int_setting(settings_pack::active_tracker_limit);
int lsd_limit = get_int_setting(settings_pack::active_lsd_limit);
int hard_limit = get_int_setting(settings_pack::active_limit);
// if hard_limit is <= 0, all torrents in these lists should be paused.
// The order is not relevant
@ -3808,7 +3800,9 @@ namespace aux {
// that are eligible for optimistic unchoke, similar to the torrents
// perhaps this could even iterate over the pool allocators of
// torrent_peer objects. It could probably be done in a single pass and
// collect the n best candidates
// collect the n best candidates. maybe just a queue of peers would make
// even more sense, just pick the next peer in the queue for unchoking. It
// would be O(1).
for (connection_map::iterator i = m_connections.begin()
, end(m_connections.end()); i != end; ++i)
{
@ -4097,8 +4091,8 @@ namespace aux {
TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK;
time_point now = aux::time_now();
time_duration unchoke_interval = now - m_last_choke;
time_point const now = aux::time_now();
time_duration const unchoke_interval = now - m_last_choke;
m_last_choke = now;
// build list of all peers that are
@ -4112,8 +4106,8 @@ namespace aux {
boost::shared_ptr<peer_connection> p = *i;
TORRENT_ASSERT(p);
++i;
torrent* t = p->associated_torrent().lock().get();
torrent_peer* pi = p->peer_info_struct();
torrent* const t = p->associated_torrent().lock().get();
torrent_peer* const pi = p->peer_info_struct();
if (p->ignore_unchoke_slots() || t == 0 || pi == 0
|| pi->web_seed || t->is_paused())
@ -4183,8 +4177,11 @@ namespace aux {
, allowed_upload_slots);
#endif
int num_opt_unchoke = m_settings.get_int(settings_pack::num_optimistic_unchoke_slots);
if (num_opt_unchoke == 0) num_opt_unchoke = (std::max)(1, allowed_upload_slots / 5);
int const unchoked_counter_optimistic
= m_stats_counters[counters::num_peers_up_unchoked_optimistic];
int const num_opt_unchoke = (unchoked_counter_optimistic == 0)
? (std::max)(1, allowed_upload_slots / 5) : unchoked_counter_optimistic;
int unchoke_set_size = allowed_upload_slots - num_opt_unchoke;
// go through all the peers and unchoke the first ones and choke
@ -6060,10 +6057,7 @@ namespace aux {
void session_impl::update_unchoke_limit()
{
int allowed_upload_slots = m_settings.get_int(settings_pack::unchoke_slots_limit);
if (allowed_upload_slots < 0)
allowed_upload_slots = (std::numeric_limits<int>::max)();
int const allowed_upload_slots = get_int_setting(settings_pack::unchoke_slots_limit);
m_stats_counters.set_value(counters::num_unchoke_slots
, allowed_upload_slots);
@ -7035,9 +7029,9 @@ namespace aux {
settings_pack::num_optimistic_unchoke_slots));
}
int unchoked_counter_all = m_stats_counters[counters::num_peers_up_unchoked_all];
int unchoked_counter = m_stats_counters[counters::num_peers_up_unchoked];
int unchoked_counter_optimistic
int const unchoked_counter_all = m_stats_counters[counters::num_peers_up_unchoked_all];
int const unchoked_counter = m_stats_counters[counters::num_peers_up_unchoked];
int const unchoked_counter_optimistic
= m_stats_counters[counters::num_peers_up_unchoked_optimistic];
TORRENT_ASSERT_VAL(unchoked_counter_all == unchokes_all, unchokes_all);

View File

@ -480,10 +480,6 @@ void test_check_files(std::string const& test_path
io.set_num_threads(0);
}
#ifdef TORRENT_NO_DEPRECATE
#define storage_mode_compact storage_mode_sparse
#endif
// TODO: 2 split this test up into smaller parts
void run_test(bool unbuffered)
{
@ -533,7 +529,7 @@ void run_test(bool unbuffered)
std::cerr << "=== test 1 === " << (unbuffered?"unbuffered":"buffered") << std::endl;
// run_storage_tests writes piece 0, 1 and 2. not 3
run_storage_tests(info, fs, test_path, storage_mode_compact, unbuffered);
run_storage_tests(info, fs, test_path, storage_mode_sparse, unbuffered);
// make sure the files have the correct size
std::string base = combine_path(test_path, "temp_storage");
@ -577,7 +573,7 @@ void run_test(bool unbuffered)
std::cerr << "=== test 3 ===" << std::endl;
run_storage_tests(info, fs, test_path, storage_mode_compact, unbuffered);
run_storage_tests(info, fs, test_path, storage_mode_sparse, unbuffered);
TEST_EQUAL(file_size(combine_path(test_path, combine_path("temp_storage", "test1.tmp"))), piece_size * 3);
remove_all(combine_path(test_path, "temp_storage"), ec);
@ -610,7 +606,7 @@ void run_test(bool unbuffered)
std::cerr << "=== test 6 ===" << std::endl;
test_check_files(test_path, storage_mode_sparse, unbuffered);
test_check_files(test_path, storage_mode_compact, unbuffered);
test_check_files(test_path, storage_mode_sparse, unbuffered);
std::cerr << "=== test 7 ===" << std::endl;
test_rename(test_path);
@ -645,7 +641,7 @@ void test_fastresume(bool const test_deprecated)
add_torrent_params p;
p.ti = boost::make_shared<torrent_info>(boost::cref(*t));
p.save_path = combine_path(test_path, "tmp1");
p.storage_mode = storage_mode_compact;
p.storage_mode = storage_mode_sparse;
torrent_handle h = ses.add_torrent(p, ec);
TEST_CHECK(exists(combine_path(p.save_path, "temporary")));
if (!exists(combine_path(p.save_path, "temporary")))
@ -710,7 +706,8 @@ void test_fastresume(bool const test_deprecated)
p.flags &= ~add_torrent_params::flag_auto_managed;
p.ti = boost::make_shared<torrent_info>(boost::cref(*t));
p.save_path = combine_path(test_path, "tmp1");
p.storage_mode = storage_mode_compact;
p.storage_mode = storage_mode_sparse;
bencode(std::back_inserter(p.resume_data), resume);
torrent_handle h = ses.add_torrent(p, ec);
alert const* a = wait_for_alert(ses, fastresume_rejected_alert::alert_type
@ -767,7 +764,7 @@ void test_rename_file_fastresume(bool test_deprecated)
add_torrent_params p;
p.ti = boost::make_shared<torrent_info>(boost::cref(*t));
p.save_path = combine_path(test_path, "tmp2");
p.storage_mode = storage_mode_compact;
p.storage_mode = storage_mode_sparse;
torrent_handle h = ses.add_torrent(p, ec);
h.rename_file(0, "testing_renamed_files");
@ -818,7 +815,8 @@ void test_rename_file_fastresume(bool test_deprecated)
}
p.ti = boost::make_shared<torrent_info>(boost::cref(*t));
p.save_path = combine_path(test_path, "tmp2");
p.storage_mode = storage_mode_compact;
p.storage_mode = storage_mode_sparse;
bencode(std::back_inserter(p.resume_data), resume);
torrent_handle h = ses.add_torrent(p, ec);
torrent_status stat;

View File

@ -455,14 +455,3 @@ TORRENT_TEST(allocate)
cleanup();
}
#ifndef TORRENT_NO_DEPRECATE
TORRENT_TEST(compact)
{
using namespace libtorrent;
fprintf(stderr, "compact mode\n");
test_transfer(0, settings_pack(), false, storage_mode_compact);
cleanup();
}
#endif

View File

@ -139,9 +139,6 @@ void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> torrent_fil
p.flags |= add_torrent_params::flag_sequential_download;
p.ti = torrent_file;
p.save_path = save_path;
#ifndef TORRENT_NO_DEPRECATE
p.storage_mode = storage_mode_compact;
#endif
torrent_handle th = ses.add_torrent(p, ec);
printf("adding torrent, save_path = \"%s\" cwd = \"%s\" torrent = \"%s\"\n"
, save_path.c_str(), current_working_directory().c_str()