diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 33b0aa0eb..18a91087f 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -982,13 +982,12 @@ namespace libtorrent } #ifdef TORRENT_VERBOSE_LOGGING - peer_log(" ==> HAVE [ piece: %d ]", index); + peer_log("==> HAVE [ piece: %d ]", index); #endif write_have(index); #ifdef TORRENT_DEBUG boost::shared_ptr t = m_torrent.lock(); TORRENT_ASSERT(t); - TORRENT_ASSERT(t->have_piece(index)); #endif } @@ -5513,7 +5512,7 @@ namespace libtorrent { // make sure upload only peers are disconnected if (t->is_upload_only() && m_upload_only) - TORRENT_ASSERT(m_disconnect_started || t->graceful_pause()); + TORRENT_ASSERT(m_disconnect_started || t->graceful_pause() || t->has_error()); if (m_upload_only && !m_interesting && m_bitfield_received @@ -5525,7 +5524,7 @@ namespace libtorrent { // none of this matters if we're disconnecting anyway if (t->is_upload_only()) - TORRENT_ASSERT(!m_interesting || t->graceful_pause()); + TORRENT_ASSERT(!m_interesting || t->graceful_pause() || t->has_error()); if (is_seed()) TORRENT_ASSERT(m_upload_only); } diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 4d2c4d670..b3eea75a2 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -2284,7 +2284,7 @@ namespace libtorrent TORRENT_ASSERT(i != m_downloads.end()); d.clear(); - for (int j = 0; j < blocks_in_piece(index); ++j) + for (int j = 0, end(blocks_in_piece(index)); j != end; ++j) { d.push_back(i->info[j].peer); } diff --git a/src/torrent.cpp b/src/torrent.cpp index 32de3a23f..bed21ab9d 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -6339,7 +6339,7 @@ namespace libtorrent if (p->outstanding_bytes() > 0) { #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING - (*p->m_logger) << "*** CHOKING PEER: torrent graceful paused\n"; + p->peer_log("*** CHOKING PEER: torrent graceful paused"); #endif // remove any un-sent requests from the queue p->clear_request_queue(); @@ -6349,7 +6349,7 @@ namespace libtorrent } #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING - (*p->m_logger) << "*** CLOSING CONNECTION: torrent_paused\n"; + p->peer_log("*** CLOSING CONNECTION: torrent_paused"); #endif p->disconnect(errors::torrent_paused); } @@ -6380,7 +6380,7 @@ namespace libtorrent for (peer_iterator i = m_connections.begin(); i != m_connections.end(); ++i) { - (*(*i)->m_logger) << time_now_string() << " *** " << message << "\n"; + (*i)->peer_log("*** %s", message); } #endif @@ -6733,7 +6733,7 @@ namespace libtorrent TORRENT_DECLARE_DUMMY(std::exception, e); (void)e; #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING - (*p->m_logger) << "**ERROR**: " << e.what() << "\n"; + p->peer_log("*** ERROR %s", e.what()); #endif p->disconnect(errors::no_error, 1); }