merged RC_1_1 into master

This commit is contained in:
arvidn 2016-11-20 11:18:16 -05:00
commit 0e33e62627
13 changed files with 157 additions and 20 deletions

View File

@ -115,6 +115,7 @@
* deprecate time functions, expose typedefs of boost::chrono in the
libtorrent namespace instead
* deprecate file_base feature in file_storage/torrent_info
* changed default piece and file priority to 4 (previously 1)
* improve piece picker support for reverse picking (used for snubbed peers)
to not cause priority inversion for regular peers
* improve piece picker to better support torrents with very large pieces

View File

@ -239,11 +239,11 @@ rule warnings ( properties * )
result += <cflags>-Wno-padded ;
result += <cflags>-Wno-global-constructors ;
result += <cxxflags>-Wno-c++98-compat ;
# this warns on any global static object, which are used for error_category
# objects
result += <cflags>-Wno-exit-time-destructors ;
result += <cflags>-Wno-documentation-unknown-command ;
result += <cflags>-Wno-disabled-macro-expansion ;
result += <cflags>-Wno-unused-command-line-argument ;
result += <cflags>-Wno-error=implicit-fallthrough ;
result += <cflags>-Wno-implicit-fallthrough ;
result += <cflags>-Wno-c++11-long-long ;
result += <cflags>-Wno-variadic-macros ;

View File

@ -54,6 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wall"
#pragma clang diagnostic ignored "-Weverything"
#pragma clang diagnostic ignored "-Wsign-conversion"
@ -77,8 +78,11 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#pragma clang diagnostic ignored "-Wgnu-folding-constant"
#pragma clang diagnostic ignored "-Wdouble-promotion"
#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
#pragma clang diagnostic ignored "-Wfloat-equal"
#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
#endif

View File

@ -989,8 +989,10 @@ namespace libtorrent
// You may however change the priority of individual pieces. There are 8
// priority levels. 0 means not to download the piece at all. Otherwise,
// lower priority values means less likely to be picked. Piece priority
// takes precedence over piece availability. Every priority-7 piece will
// be attempted to be picked before a priority 6 piece and so on.
// takes precedence over piece availability. Every piece with priority 7
// will be attempted to be picked before a priority 6 piece and so on.
//
// The default priority of pieces is 4.
//
// Piece priorities can not be changed for torrents that have not
// downloaded the metadata yet. For instance, magnet links and torrents

@ -1 +1 @@
Subproject commit 3eae1da7de7d13ab26472c4a44ee4477ce24fa26
Subproject commit e450864958668f8c2ecf8b9839fa278c9c797571

View File

@ -75,23 +75,23 @@ TORRENT_TEST(status_timers)
if ((ticks % 3600) == 0)
{
lt::time_point now = lt::clock_type::now();
int const since_start = int(total_seconds(now - start_time) - 1);
auto const since_start = duration_cast<seconds>(now - start_time) - lt::seconds(1);
torrent_status st = handle.status();
TEST_EQUAL(st.active_time, since_start);
TEST_EQUAL(st.seeding_time, since_start);
TEST_EQUAL(st.finished_time, since_start);
TEST_EQUAL(st.last_scrape, -1);
TEST_EQUAL(st.time_since_upload, -1);
TEST_CHECK(st.active_duration == since_start);
TEST_CHECK(st.seeding_duration == since_start);
TEST_CHECK(st.finished_duration == since_start);
TEST_CHECK(st.last_upload < start_time);
// checking the torrent counts as downloading
// eventually though, we've forgotten about it and go back to -1
if (since_start > 65000)
if (since_start > lt::seconds(65000))
{
TEST_EQUAL(st.time_since_download, -1);
TEST_CHECK(st.last_download < start_time);
}
else
{
TEST_EQUAL(st.time_since_download, since_start);
// TODO: this should really be a proximity-check
TEST_CHECK(st.last_download == start_time + lt::seconds(1));
}
}

View File

@ -449,3 +449,37 @@ TORRENT_TEST(multi_file_unaligned_redirect)
}
);
}
TORRENT_TEST(urlseed_timeout)
{
bool timeout = false;
run_test(
[](lt::session& ses)
{
file_storage fs;
fs.add_file("timeout_test", 0x8000);
lt::add_torrent_params params = ::create_torrent(fs);
params.url_seeds.push_back("http://2.2.2.2:8080/");
params.flags &= ~lt::add_torrent_params::flag_auto_managed;
params.flags &= ~lt::add_torrent_params::flag_paused;
params.save_path = ".";
ses.async_add_torrent(params);
},
[&timeout](lt::session& ses, lt::alert const* alert) {
const lt::peer_disconnected_alert *pda = lt::alert_cast<lt::peer_disconnected_alert>(alert);
if (pda && pda->error == errors::timed_out_inactivity){
timeout = true;
}
},
[](sim::simulation& sim, lt::session& ses)
{
sim::asio::io_service web_server(sim, address_v4::from_string("2.2.2.2"));
// listen on port 8080
sim::http_server http(web_server, 8080);
http.register_stall_handler("/timeout_test");
sim.run();
}
);
TEST_EQUAL(timeout, true);
}

View File

@ -39,7 +39,9 @@ POSSIBILITY OF SUCH DAMAGE.
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-macros"
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#endif
// these defines are just in case the system we're on needs them for 64 bit file
@ -136,8 +138,6 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#undef _FILE_OFFSET_BITS
// make sure the _FILE_OFFSET_BITS define worked
// on this platform. It's supposed to make file
// related functions support 64-bit offsets.

View File

@ -79,9 +79,9 @@ namespace libtorrent { namespace dht
#ifndef TORRENT_DISABLE_LOGGING
if (logger != nullptr && logger->should_log(dht_logger::tracker))
{
logger->log(dht_logger::tracker, "BANNING PEER [ ip: %s time: %f count: %d ]"
logger->log(dht_logger::tracker, "BANNING PEER [ ip: %s time: %d ms count: %d ]"
, print_address(addr).c_str()
, total_milliseconds((now - match->limit) + seconds(10)) / 1000.0
, int(total_milliseconds((now - match->limit) + seconds(10)))
, match->count);
}
#else

View File

@ -5591,6 +5591,7 @@ namespace libtorrent
&peer_connection::on_send_data, self(), _1, _2)));
m_channel_state[upload_channel] |= peer_info::bw_network;
m_last_sent = aux::time_now();
}
void peer_connection::on_disk()
@ -6554,7 +6555,6 @@ namespace libtorrent
peer_log(peer_log_alert::outgoing_message, "KEEPALIVE");
#endif
m_last_sent = aux::time_now();
write_keepalive();
}

View File

@ -145,6 +145,7 @@ test-suite libtorrent :
test_stat_cache.cpp
test_enum_net.cpp
test_linked_list.cpp
test_stack_allocator.cpp
test_file_progress.cpp ]
[ run test_piece_picker.cpp ]

View File

@ -19,6 +19,7 @@ test_programs = \
test_resume \
test_read_resume \
test_ssl \
test_stack_allocator \
test_storage \
test_time_critical \
test_torrent \
@ -210,6 +211,7 @@ test_storage_SOURCES = test_storage.cpp
test_time_critical_SOURCES = test_time_critical.cpp
test_resume_SOURCES = test_resume.cpp
test_read_resume_SOURCES = test_read_resume.cpp
test_stack_allocator_SOURCES = test_stack_allocator.cpp
test_ssl_SOURCES = test_ssl.cpp
test_torrent_SOURCES = test_torrent.cpp
test_tracker_SOURCES = test_tracker.cpp

View File

@ -0,0 +1,93 @@
/*
Copyright (c) 2016, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.hpp"
#include "libtorrent/stack_allocator.hpp"
using libtorrent::aux::stack_allocator;
TORRENT_TEST(copy_string)
{
stack_allocator a;
int const idx1 = a.copy_string("testing");
// attempt to trigger a reallocation
a.allocate(100000);
int const idx2 = a.copy_string(std::string("foobar"));
TEST_CHECK(strcmp(a.ptr(idx1), "testing") == 0);
TEST_CHECK(strcmp(a.ptr(idx2), "foobar") == 0);
}
TORRENT_TEST(copy_buffer)
{
stack_allocator a;
int const idx1 = a.copy_buffer(libtorrent::span<char const>("testing"));
// attempt to trigger a reallocation
a.allocate(100000);
TEST_CHECK(strcmp(a.ptr(idx1), "testing") == 0);
}
TORRENT_TEST(allocate)
{
stack_allocator a;
int const idx1 = a.allocate(100);
char* ptr = a.ptr(idx1);
for (int i = 0; i < 100; ++i)
ptr[i] = char(i % 256);
// attempt to trigger a reallocation
a.allocate(100000);
ptr = a.ptr(idx1);
for (int i = 0; i < 100; ++i)
TEST_CHECK(ptr[i] == char(i % 256));
}
TORRENT_TEST(swap)
{
stack_allocator a1;
stack_allocator a2;
int const idx1 = a1.copy_string("testing");
int const idx2 = a2.copy_string("foobar");
a1.swap(a2);
TEST_CHECK(strcmp(a1.ptr(idx2), "foobar") == 0);
TEST_CHECK(strcmp(a2.ptr(idx1), "testing") == 0);
}