fixing up some asserts and verbose logging

This commit is contained in:
Arvid Norberg 2011-08-13 18:46:52 +00:00
parent 3ef2cd8d6d
commit 1d40d7aad9
3 changed files with 8 additions and 9 deletions

View File

@ -982,13 +982,12 @@ namespace libtorrent
} }
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
peer_log(" ==> HAVE [ piece: %d ]", index); peer_log("==> HAVE [ piece: %d ]", index);
#endif #endif
write_have(index); write_have(index);
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG
boost::shared_ptr<torrent> t = m_torrent.lock(); boost::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->have_piece(index));
#endif #endif
} }
@ -5513,7 +5512,7 @@ namespace libtorrent
{ {
// make sure upload only peers are disconnected // make sure upload only peers are disconnected
if (t->is_upload_only() && m_upload_only) 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 if (m_upload_only
&& !m_interesting && !m_interesting
&& m_bitfield_received && m_bitfield_received
@ -5525,7 +5524,7 @@ namespace libtorrent
{ {
// none of this matters if we're disconnecting anyway // none of this matters if we're disconnecting anyway
if (t->is_upload_only()) 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()) if (is_seed())
TORRENT_ASSERT(m_upload_only); TORRENT_ASSERT(m_upload_only);
} }

View File

@ -2284,7 +2284,7 @@ namespace libtorrent
TORRENT_ASSERT(i != m_downloads.end()); TORRENT_ASSERT(i != m_downloads.end());
d.clear(); 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); d.push_back(i->info[j].peer);
} }

View File

@ -6339,7 +6339,7 @@ namespace libtorrent
if (p->outstanding_bytes() > 0) if (p->outstanding_bytes() > 0)
{ {
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING #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 #endif
// remove any un-sent requests from the queue // remove any un-sent requests from the queue
p->clear_request_queue(); p->clear_request_queue();
@ -6349,7 +6349,7 @@ namespace libtorrent
} }
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING #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 #endif
p->disconnect(errors::torrent_paused); p->disconnect(errors::torrent_paused);
} }
@ -6380,7 +6380,7 @@ namespace libtorrent
for (peer_iterator i = m_connections.begin(); for (peer_iterator i = m_connections.begin();
i != m_connections.end(); ++i) i != m_connections.end(); ++i)
{ {
(*(*i)->m_logger) << time_now_string() << " *** " << message << "\n"; (*i)->peer_log("*** %s", message);
} }
#endif #endif
@ -6733,7 +6733,7 @@ namespace libtorrent
TORRENT_DECLARE_DUMMY(std::exception, e); TORRENT_DECLARE_DUMMY(std::exception, e);
(void)e; (void)e;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
(*p->m_logger) << "**ERROR**: " << e.what() << "\n"; p->peer_log("*** ERROR %s", e.what());
#endif #endif
p->disconnect(errors::no_error, 1); p->disconnect(errors::no_error, 1);
} }