merged RC_1_1 into master

This commit is contained in:
arvidn 2016-06-11 01:00:41 -04:00
commit dfc2206b9f
9 changed files with 27 additions and 19 deletions

View File

@ -64,10 +64,6 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0, void*
TORRENT_EXPORT void assert_print(char const* fmt, ...) TORRENT_FORMAT(1,2);
// internal
#if (TORRENT_USE_ASSERTS || defined TORRENT_ASIO_DEBUGGING) \
&& !defined TORRENT_PRODUCTION_ASSERTS
TORRENT_NO_RETURN
#endif
TORRENT_EXPORT void assert_fail(const char* expr, int line
, char const* file, char const* function, char const* val, int kind = 0);

View File

@ -296,9 +296,13 @@ TORRENT_EXPORT void assert_print(char const* fmt, ...)
#endif
}
#ifndef TORRENT_PRODUCTION_ASSERTS
TORRENT_NO_RETURN
// we deliberately don't want asserts to be marked as no-return, since that
// would trigger warnings in debug builds of any code coming after the assert
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
#endif
TORRENT_EXPORT void assert_fail(char const* expr, int line
, char const* file, char const* function, char const* value, int kind)
{
@ -351,6 +355,10 @@ TORRENT_EXPORT void assert_fail(char const* expr, int line
#endif
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#elif !TORRENT_USE_ASSERTS
// these are just here to make it possible for a client that built with debug

View File

@ -1340,7 +1340,7 @@ void block_cache::insert_blocks(cached_piece_entry* pe, int block, file::iovec_t
TORRENT_ASSERT(iov[i].iov_base);
#ifdef TORRENT_DEBUG_BUFFERS
TORRENT_PIECE_ASSERT(is_disk_buffer((char*)iov[i].iov_base), pe);
TORRENT_PIECE_ASSERT(is_disk_buffer(static_cast<char*>(iov[i].iov_base)), pe);
#endif
if (pe->blocks[block].buf && (flags & blocks_inc_refcount))

View File

@ -361,7 +361,7 @@ namespace libtorrent
, end(peers.end()); i != end; ++i)
{
peer_connection const& p = **i;
int rate = int(p.uploaded_in_last_round()
int const rate = int(p.uploaded_in_last_round()
* 1000 / total_milliseconds(unchoke_interval));
if (rate < rate_threshold) break;
@ -385,7 +385,7 @@ namespace libtorrent
if (sett.get_int(settings_pack::seed_choking_algorithm)
== settings_pack::round_robin)
{
int pieces = sett.get_int(settings_pack::seeding_piece_quota);
int const pieces = sett.get_int(settings_pack::seeding_piece_quota);
std::partial_sort(peers.begin(), peers.begin()
+ (std::min)(upload_slots, int(peers.size())), peers.end()
@ -407,12 +407,12 @@ namespace libtorrent
}
else
{
TORRENT_ASSERT_FAIL();
int pieces = sett.get_int(settings_pack::seeding_piece_quota);
int const pieces = sett.get_int(settings_pack::seeding_piece_quota);
std::partial_sort(peers.begin(), peers.begin()
+ (std::min)(upload_slots, int(peers.size())), peers.end()
, std::bind(&unchoke_compare_rr, _1, _2, pieces));
TORRENT_ASSERT_FAIL();
}
return upload_slots;

View File

@ -280,9 +280,8 @@ void traversal_algorithm::traverse(node_id const& id, udp::endpoint addr)
void traversal_algorithm::finished(observer_ptr o)
{
#ifdef TORRENT_DEBUG
#if TORRENT_USE_ASSERTS
auto i = std::find(m_results.begin(), m_results.end(), o);
TORRENT_ASSERT(i != m_results.end() || m_results.size() == 100);
#endif

View File

@ -293,6 +293,8 @@ namespace libtorrent
// not implemented
TORRENT_ASSERT_FAIL();
ec.assign(boost::system::errc::operation_not_supported
, boost::system::generic_category());
}
void part_file::export_file(file& f, boost::int64_t offset, boost::int64_t size, error_code& ec)

View File

@ -3037,10 +3037,11 @@ namespace libtorrent
TORRENT_ASSERT(p.start == j->d.io.offset);
TORRENT_ASSERT(picker.num_peers(block_finished) == 0);
if (j->ret == -1 && j->error.ec == boost::system::errc::operation_canceled)
if (j->ret == -1
&& j->error.ec == boost::system::errc::operation_canceled)
{
TORRENT_ASSERT_FAIL(); // how do we get here?
picker.mark_as_canceled(block_finished, peer_info_struct());
TORRENT_ASSERT_FAIL(); // how do we get here?
return;
}
// std::fprintf(stderr, "peer_connection mark_as_finished peer: %p piece: %d block: %d\n"

View File

@ -88,7 +88,7 @@ namespace
tcp::endpoint const& m_ep;
};
#if TORRENT_USE_ASSERTS
#ifndef TORRENT_DISABLE_INVARIANT_CHECKS
struct match_peer_connection
{
match_peer_connection(peer_connection_interface const& c) : m_conn(c) {}
@ -101,7 +101,9 @@ namespace
peer_connection_interface const& m_conn;
};
#endif
#if TORRENT_USE_ASSERTS
struct match_peer_connection_or_endpoint
{
match_peer_connection_or_endpoint(peer_connection_interface const& c) : m_conn(c) {}

View File

@ -184,7 +184,7 @@ boost::shared_ptr<piece_picker> setup_picker(
TEST_CHECK(avail == availability_vec[i]);
}
#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
#if TORRENT_USE_INVARIANT_CHECKS
p->check_invariant();
#endif
return p;
@ -193,7 +193,7 @@ boost::shared_ptr<piece_picker> setup_picker(
bool verify_pick(boost::shared_ptr<piece_picker> p
, std::vector<piece_block> const& picked, bool allow_multi_blocks = false)
{
#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS
#if TORRENT_USE_INVARIANT_CHECKS
p->check_invariant();
#endif
if (!allow_multi_blocks)