add disk I/O read asserts and fix i2p issue if a tracker responds with i2p peers when i2p is not configured on the client

This commit is contained in:
arvidn 2015-08-28 07:20:21 -04:00
parent 6012306557
commit beb5455331
3 changed files with 21 additions and 4 deletions

View File

@ -2291,10 +2291,9 @@ namespace libtorrent
{
#ifndef TORRENT_DISABLE_LOGGING
peer_log(peer_log_alert::info, "INVALID_REQUEST", "peer is not interested "
" t: %d n: %d h: %d block_limit: %d"
" t: %d n: %d block_limit: %d"
, int(t->torrent_file().piece_size(r.piece))
, t->torrent_file().num_pieces()
, t->has_piece_passed(r.piece)
, t->block_size());
peer_log(peer_log_alert::info, "INTERESTED", "artificial incoming INTERESTED message");
#endif
@ -2421,6 +2420,10 @@ namespace libtorrent
if (m_requests.empty())
m_counters.inc_stats_counter(counters::num_peers_up_requests);
TORRENT_ASSERT(t->valid_metadata());
TORRENT_ASSERT(r.piece >= 0);
TORRENT_ASSERT(r.piece < t->torrent_file().num_pieces());
m_requests.push_back(r);
if (t->alerts().should_post<incoming_request_alert>())
@ -5155,6 +5158,11 @@ namespace libtorrent
// the callback function may be called immediately, instead of being posted
if (!t->need_loaded()) return;
TORRENT_ASSERT(t->valid_metadata());
TORRENT_ASSERT(r.piece >= 0);
TORRENT_ASSERT(r.piece < t->torrent_file().num_pieces());
t->inc_refcount("async_read");
m_disk_thread.async_read(&t->storage(), r
, boost::bind(&peer_connection::on_disk_read_complete

View File

@ -1275,8 +1275,10 @@ namespace aux {
req.ssl_ctx = &m_ssl_ctx;
#endif
#if TORRENT_USE_I2P
req.i2pconn = &m_i2p_conn;
req.kind |= tracker_request::i2p;
if (!m_settings.get_str(settings_pack::i2p_hostname).empty())
{
req.i2pconn = &m_i2p_conn;
}
#endif
if (is_any(req.bind_ip)) req.bind_ip = m_listen_interface.address();

View File

@ -3195,6 +3195,13 @@ namespace libtorrent
req.auth = tracker_login();
req.key = tracker_key();
#ifdef TORRENT_USE_OPENSSL
if (is_i2p())
{
req.kind |= tracker_request::i2p;
}
#endif
#ifndef TORRENT_DISABLE_LOGGING
debug_log("==> TRACKER REQUEST \"%s\" event: %s abort: %d"
, req.url.c_str()