forked from premiere/premiere-libtorrent
some more asserts related to bandwidth manager
This commit is contained in:
parent
948f53a8af
commit
ac28fa7b62
|
@ -203,10 +203,23 @@ struct bandwidth_manager
|
||||||
m_history_timer.cancel();
|
m_history_timer.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
bool is_queued(PeerConnection const* peer)
|
||||||
|
{
|
||||||
|
for (typename queue_t::iterator i = m_queue.begin()
|
||||||
|
, end(m_queue.end()); i != end; ++i)
|
||||||
|
{
|
||||||
|
if (i->peer.get() == peer) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// non prioritized means that, if there's a line for bandwidth,
|
// non prioritized means that, if there's a line for bandwidth,
|
||||||
// others will cut in front of the non-prioritized peers.
|
// others will cut in front of the non-prioritized peers.
|
||||||
// this is used by web seeds
|
// this is used by web seeds
|
||||||
void request_bandwidth(intrusive_ptr<PeerConnection> peer
|
void request_bandwidth(intrusive_ptr<PeerConnection> const& peer
|
||||||
, int blk
|
, int blk
|
||||||
, bool non_prioritized) throw()
|
, bool non_prioritized) throw()
|
||||||
{
|
{
|
||||||
|
@ -217,13 +230,7 @@ struct bandwidth_manager
|
||||||
|
|
||||||
// make sure this peer isn't already in line
|
// make sure this peer isn't already in line
|
||||||
// waiting for bandwidth
|
// waiting for bandwidth
|
||||||
#ifndef NDEBUG
|
TORRENT_ASSERT(!is_queued(peer.get()));
|
||||||
for (typename queue_t::iterator i = m_queue.begin()
|
|
||||||
, end(m_queue.end()); i != end; ++i)
|
|
||||||
{
|
|
||||||
TORRENT_ASSERT(i->peer < peer || peer < i->peer);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
boost::shared_ptr<Torrent> t = peer->associated_torrent().lock();
|
boost::shared_ptr<Torrent> t = peer->associated_torrent().lock();
|
||||||
|
|
||||||
|
|
|
@ -665,6 +665,10 @@ namespace libtorrent
|
||||||
// request is in progress.
|
// request is in progress.
|
||||||
bool m_writing;
|
bool m_writing;
|
||||||
bool m_reading;
|
bool m_reading;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
bool m_requested_write_quota;
|
||||||
|
bool m_requested_read_quota;
|
||||||
|
#endif
|
||||||
|
|
||||||
// if set to non-zero, this peer will always prefer
|
// if set to non-zero, this peer will always prefer
|
||||||
// to request entire n pieces, rather than blocks.
|
// to request entire n pieces, rather than blocks.
|
||||||
|
|
|
@ -132,6 +132,10 @@ namespace libtorrent
|
||||||
+ boost::lexical_cast<std::string>(m_remote.port()), m_ses.listen_port());
|
+ boost::lexical_cast<std::string>(m_remote.port()), m_ses.listen_port());
|
||||||
(*m_logger) << "*** OUTGOING CONNECTION\n";
|
(*m_logger) << "*** OUTGOING CONNECTION\n";
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef NDEBUG
|
||||||
|
m_requested_read_quota = false;
|
||||||
|
m_requested_write_quota = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||||
TORRENT_ASSERT(t);
|
TORRENT_ASSERT(t);
|
||||||
|
@ -215,6 +219,10 @@ namespace libtorrent
|
||||||
(*m_logger) << "*** INCOMING CONNECTION\n";
|
(*m_logger) << "*** INCOMING CONNECTION\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
m_requested_read_quota = false;
|
||||||
|
m_requested_write_quota = false;
|
||||||
|
#endif
|
||||||
std::fill(m_peer_id.begin(), m_peer_id.end(), 0);
|
std::fill(m_peer_id.begin(), m_peer_id.end(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2380,12 +2388,20 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_writing);
|
TORRENT_ASSERT(m_writing);
|
||||||
m_writing = false;
|
m_writing = false;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
TORRENT_ASSERT(m_requested_write_quota);
|
||||||
|
m_requested_write_quota = false;
|
||||||
|
#endif
|
||||||
setup_send();
|
setup_send();
|
||||||
}
|
}
|
||||||
else if (channel == download_channel)
|
else if (channel == download_channel)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_reading);
|
TORRENT_ASSERT(m_reading);
|
||||||
m_reading = false;
|
m_reading = false;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
TORRENT_ASSERT(m_requested_read_quota);
|
||||||
|
m_requested_read_quota = false;
|
||||||
|
#endif
|
||||||
setup_receive();
|
setup_receive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2434,6 +2450,10 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(!m_writing);
|
TORRENT_ASSERT(!m_writing);
|
||||||
// peers that we are not interested in are non-prioritized
|
// peers that we are not interested in are non-prioritized
|
||||||
m_writing = true;
|
m_writing = true;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
TORRENT_ASSERT(!m_requested_write_quota);
|
||||||
|
m_requested_write_quota = true;
|
||||||
|
#endif
|
||||||
t->request_bandwidth(upload_channel, self()
|
t->request_bandwidth(upload_channel, self()
|
||||||
, !(is_interesting() && !has_peer_choked()));
|
, !(is_interesting() && !has_peer_choked()));
|
||||||
}
|
}
|
||||||
|
@ -2488,6 +2508,10 @@ namespace libtorrent
|
||||||
(*m_logger) << "req bandwidth [ " << download_channel << " ]\n";
|
(*m_logger) << "req bandwidth [ " << download_channel << " ]\n";
|
||||||
#endif
|
#endif
|
||||||
m_reading = true;
|
m_reading = true;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
TORRENT_ASSERT(!m_requested_read_quota);
|
||||||
|
m_requested_read_quota = true;
|
||||||
|
#endif
|
||||||
t->request_bandwidth(download_channel, self(), m_non_prioritized);
|
t->request_bandwidth(download_channel, self(), m_non_prioritized);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue