*** empty log message ***
This commit is contained in:
parent
726a8b57b6
commit
23288c74f5
|
@ -61,7 +61,7 @@ namespace libtorrent
|
|||
: alert(alert::info, msg)
|
||||
, handle(h)
|
||||
, piece_index(index)
|
||||
{}
|
||||
{ assert(index >= 0);}
|
||||
|
||||
virtual std::auto_ptr<alert> clone() const
|
||||
{ return std::auto_ptr<alert>(new hash_failed_alert(*this)); }
|
||||
|
|
|
@ -132,6 +132,7 @@ namespace libtorrent
|
|||
template<class InIt>
|
||||
std::string read_string(InIt& in, InIt end, int len)
|
||||
{
|
||||
assert(len>=0);
|
||||
std::string ret;
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace libtorrent
|
|||
struct logger
|
||||
{
|
||||
logger& operator<<(const char* t)
|
||||
{ log(t); return *this; }
|
||||
{ assert(t); log(t); return *this; }
|
||||
logger& operator<<(const std::string& t)
|
||||
{ log(t.c_str()); return *this; }
|
||||
logger& operator<<(int i)
|
||||
|
@ -103,8 +103,8 @@ namespace libtorrent
|
|||
public:
|
||||
file_logger(const char* filename)
|
||||
: m_file(filename)
|
||||
{}
|
||||
virtual void log(const char* text) { m_file << text; }
|
||||
{ assert(filename); }
|
||||
virtual void log(const char* text) { assert(text); m_file << text; }
|
||||
|
||||
std::ofstream m_file;
|
||||
};
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace libtorrent
|
|||
, revision_version(revision)
|
||||
, tag_version(tag)
|
||||
{
|
||||
assert(id_string);
|
||||
assert(major >= 0 && major < 10);
|
||||
assert(minor >= 0 && minor < 10);
|
||||
assert(revision >= 0 && revision < 10);
|
||||
|
|
|
@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef TORRENT_HASHER_HPP_INCLUDED
|
||||
#define TORRENT_HASHER_HPP_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
typedef struct {
|
||||
|
@ -59,7 +61,7 @@ namespace libtorrent
|
|||
adler32_crc(): m_adler(adler32(0, 0, 0)) {}
|
||||
|
||||
void update(const char* data, int len)
|
||||
{ m_adler = adler32(m_adler, data, len); }
|
||||
{ assert(data); assert(len>0); m_adler = adler32(m_adler, data, len); }
|
||||
unsigned long final() const { return m_adler; }
|
||||
void reset() { m_adler = adler32(0, 0, 0); }
|
||||
|
||||
|
@ -74,8 +76,8 @@ namespace libtorrent
|
|||
public:
|
||||
|
||||
hasher() { SHA1Init(&m_context); }
|
||||
void update(const char* data, unsigned int len)
|
||||
{ SHA1Update(&m_context, reinterpret_cast<unsigned char*>(const_cast<char*>(data)), len); }
|
||||
void update(const char* data, int len)
|
||||
{ assert(data); assert(len>0); SHA1Update(&m_context, reinterpret_cast<unsigned char*>(const_cast<char*>(data)), len); }
|
||||
|
||||
sha1_hash final()
|
||||
{
|
||||
|
|
|
@ -62,6 +62,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/debug.hpp"
|
||||
#include "libtorrent/alert.hpp"
|
||||
#include "libtorrent/torrent_handle.hpp"
|
||||
#include "libtorrent/torrent.hpp"
|
||||
|
||||
// TODO: each time a block is 'taken over'
|
||||
// from another peer. That peer must be given
|
||||
|
@ -228,6 +229,7 @@ namespace libtorrent
|
|||
// it will let the peer know that we have the given piece
|
||||
void announce_piece(int index)
|
||||
{
|
||||
assert(index >= 0 && index < m_torrent->torrent_file().num_pieces());
|
||||
m_announce_queue.push_back(index);
|
||||
}
|
||||
|
||||
|
@ -252,7 +254,9 @@ namespace libtorrent
|
|||
void keep_alive();
|
||||
|
||||
const peer_id& id() const { return m_peer_id; }
|
||||
bool has_piece(int i) const { return m_have_piece[i]; }
|
||||
bool has_piece(int i) const
|
||||
{ assert(i >= 0 && i < m_torrent->torrent_file().num_pieces());
|
||||
return m_have_piece[i]; }
|
||||
|
||||
const std::deque<piece_block>& download_queue() const
|
||||
{ return m_download_queue; }
|
||||
|
@ -456,7 +460,7 @@ namespace libtorrent
|
|||
// seperately on payload and protocol data.
|
||||
struct range
|
||||
{
|
||||
range(int s, int l): start(s), length(l) {}
|
||||
range(int s, int l): start(s), length(l) { assert(s>=0); assert(l>0);}
|
||||
int start;
|
||||
int length;
|
||||
};
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace libtorrent
|
|||
piece_block(int p_index, int b_index)
|
||||
: piece_index(p_index)
|
||||
, block_index(b_index)
|
||||
{}
|
||||
{ assert(p_index>=0); assert(b_index>=0); }
|
||||
int piece_index;
|
||||
int block_index;
|
||||
bool operator==(const piece_block& b) const
|
||||
|
@ -191,7 +191,7 @@ namespace libtorrent
|
|||
// functor that compares indices on downloading_pieces
|
||||
struct has_index
|
||||
{
|
||||
has_index(int i): index(i) {}
|
||||
has_index(int i): index(i) { assert(i>=0); }
|
||||
bool operator()(const downloading_piece& p) const
|
||||
{ return p.index == index; }
|
||||
int index;
|
||||
|
@ -209,7 +209,7 @@ namespace libtorrent
|
|||
: peer_count(peer_count_)
|
||||
, downloading(0)
|
||||
, index(index_)
|
||||
{}
|
||||
{ assert(peer_count_>=0); assert(index_>=0); }
|
||||
|
||||
// selects which vector to look in
|
||||
unsigned peer_count : 7;
|
||||
|
@ -267,6 +267,7 @@ namespace libtorrent
|
|||
|
||||
inline int piece_picker::blocks_in_piece(int index) const
|
||||
{
|
||||
assert(index>=0 && (unsigned)index < m_piece_map.size());
|
||||
if (index+1 == m_piece_map.size())
|
||||
return m_blocks_in_last_piece;
|
||||
else
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace
|
|||
template <class T>
|
||||
void call_destructor(T* o)
|
||||
{
|
||||
assert(o);
|
||||
o->~T();
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +175,7 @@ namespace libtorrent
|
|||
|
||||
void entry::print(std::ostream& os, int indent) const
|
||||
{
|
||||
assert(indent >= 0);
|
||||
for (int i = 0; i < indent; ++i) os << " ";
|
||||
switch (m_type)
|
||||
{
|
||||
|
|
|
@ -185,7 +185,8 @@ namespace libtorrent
|
|||
|
||||
void seek(size_type pos, seek_mode from_where)
|
||||
{
|
||||
assert(pos >= 0);
|
||||
assert(pos >= 0 || from_where != seek_begin);
|
||||
assert(pos <= 0 || from_where != seek_end);
|
||||
LARGE_INTEGER offs;
|
||||
offs.QuadPart = pos;
|
||||
if (FALSE == SetFilePointerEx(
|
||||
|
|
|
@ -205,6 +205,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::set_send_quota(int num_bytes)
|
||||
{
|
||||
assert(num_bytes>=0 || num_bytes==-1);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(num_bytes <= m_send_quota_limit || m_send_quota_limit == -1);
|
||||
|
@ -321,6 +322,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_choke(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_packet_size != 1)
|
||||
|
@ -354,6 +356,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_unchoke(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_packet_size != 1)
|
||||
|
@ -374,6 +377,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_interested(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_packet_size != 1)
|
||||
|
@ -394,6 +398,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_not_interested(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_packet_size != 1)
|
||||
|
@ -417,6 +422,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_have(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_packet_size != 5)
|
||||
|
@ -461,6 +467,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_bitfield(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_packet_size - 1 != (m_have_piece.size() + 7) / 8)
|
||||
|
@ -528,6 +535,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_request(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_packet_size != 13)
|
||||
|
@ -595,6 +603,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_piece(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_recv_pos - received <= 9)
|
||||
|
@ -742,6 +751,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_cancel(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_packet_size != 13)
|
||||
|
@ -779,6 +789,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_extension_list(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_packet_size > 100 * 1024)
|
||||
|
@ -829,6 +840,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_extended(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -904,6 +916,7 @@ namespace libtorrent
|
|||
|
||||
bool peer_connection::dispatch_message(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_recv_pos >= received);
|
||||
|
@ -935,6 +948,8 @@ namespace libtorrent
|
|||
|
||||
assert(block.piece_index >= 0);
|
||||
assert(block.piece_index < m_torrent->torrent_file().num_pieces());
|
||||
assert(block.block_index >= 0);
|
||||
assert(block.block_index < m_torrent->torrent_file().piece_size(block.piece_index));
|
||||
assert(m_torrent->picker().is_downloading(block));
|
||||
|
||||
m_torrent->picker().abort_download(block);
|
||||
|
@ -983,6 +998,8 @@ namespace libtorrent
|
|||
|
||||
assert(block.piece_index >= 0);
|
||||
assert(block.piece_index < m_torrent->torrent_file().num_pieces());
|
||||
assert(block.block_index >= 0);
|
||||
assert(block.block_index < m_torrent->torrent_file().piece_size(block.piece_index));
|
||||
assert(!m_torrent->picker().is_downloading(block));
|
||||
|
||||
m_torrent->picker().mark_as_downloading(block, m_socket->sender());
|
||||
|
@ -1166,6 +1183,8 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::send_have(int index)
|
||||
{
|
||||
assert(index >= 0);
|
||||
assert(index < m_torrent->torrent_file().num_pieces());
|
||||
INVARIANT_CHECK;
|
||||
|
||||
// optimization, don't send have messages
|
||||
|
@ -1536,7 +1555,7 @@ namespace libtorrent
|
|||
// requested block. Have a limit of how much of the requested
|
||||
// block is actually read at a time.
|
||||
while (!m_requests.empty()
|
||||
&& ((int)m_send_buffer.size() < m_torrent->block_size())
|
||||
&& (m_send_buffer.size() < (unsigned)m_torrent->block_size())
|
||||
&& !m_choked)
|
||||
{
|
||||
peer_request& r = m_requests.front();
|
||||
|
|
|
@ -59,6 +59,9 @@ namespace libtorrent
|
|||
, m_downloading_piece_info(2)
|
||||
, m_piece_map((total_num_blocks + blocks_per_piece-1) / blocks_per_piece)
|
||||
{
|
||||
assert(blocks_per_piece>0);
|
||||
assert(total_num_blocks>0);
|
||||
|
||||
m_blocks_per_piece = blocks_per_piece;
|
||||
m_blocks_in_last_piece = total_num_blocks % blocks_per_piece;
|
||||
if (m_blocks_in_last_piece == 0) m_blocks_in_last_piece = blocks_per_piece;
|
||||
|
@ -100,7 +103,7 @@ namespace libtorrent
|
|||
++i)
|
||||
{
|
||||
int index = *i;
|
||||
assert(index < (int)m_piece_map.size());
|
||||
assert(index >= 0 && index < (int)m_piece_map.size());
|
||||
assert(m_piece_map[index].index == 0xffffff);
|
||||
|
||||
int peer_count = m_piece_map[index].peer_count;
|
||||
|
@ -247,6 +250,8 @@ namespace libtorrent
|
|||
|
||||
void piece_picker::move(bool downloading, int peer_count, int elem_index)
|
||||
{
|
||||
assert(peer_count >= 0);
|
||||
assert(elem_index >= 0);
|
||||
std::vector<std::vector<int> >& src_vec = (downloading)?m_downloading_piece_info:m_piece_info;
|
||||
|
||||
assert((int)src_vec.size() > peer_count);
|
||||
|
@ -295,6 +300,9 @@ namespace libtorrent
|
|||
|
||||
void piece_picker::remove(bool downloading, int peer_count, int elem_index)
|
||||
{
|
||||
assert(peer_count >= 0);
|
||||
assert(elem_index >= 0);
|
||||
|
||||
std::vector<std::vector<int> >& src_vec = (downloading)?m_downloading_piece_info:m_piece_info;
|
||||
|
||||
assert((int)src_vec.size() > peer_count);
|
||||
|
@ -385,7 +393,7 @@ namespace libtorrent
|
|||
|
||||
void piece_picker::we_have(int index)
|
||||
{
|
||||
assert(index < (int)m_piece_map.size());
|
||||
assert(index >= 0 && index < (int)m_piece_map.size());
|
||||
int info_index = m_piece_map[index].index;
|
||||
int peer_count = m_piece_map[index].peer_count;
|
||||
|
||||
|
@ -402,6 +410,7 @@ namespace libtorrent
|
|||
std::vector<piece_block>& interesting_pieces,
|
||||
int num_blocks) const
|
||||
{
|
||||
assert(num_blocks>0);
|
||||
assert(pieces.size() == m_piece_map.size());
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -443,11 +452,13 @@ namespace libtorrent
|
|||
std::vector<piece_block>& interesting_blocks,
|
||||
int num_blocks) const
|
||||
{
|
||||
assert(num_blocks>0);
|
||||
|
||||
for (std::vector<int>::const_iterator i = piece_list.begin();
|
||||
i != piece_list.end();
|
||||
++i)
|
||||
{
|
||||
assert(*i >= 0);
|
||||
assert(*i < (int)m_piece_map.size());
|
||||
// if the peer doesn't have the piece
|
||||
// skip it
|
||||
|
@ -513,8 +524,10 @@ namespace libtorrent
|
|||
|
||||
bool piece_picker::is_downloading(piece_block block) const
|
||||
{
|
||||
assert(block.piece_index >= 0);
|
||||
assert(block.block_index >= 0);
|
||||
assert(block.piece_index < (int)m_piece_map.size());
|
||||
assert(block.block_index < max_blocks_per_piece);
|
||||
assert(block.block_index < (int)max_blocks_per_piece);
|
||||
|
||||
if (m_piece_map[block.piece_index].downloading == 0) return false;
|
||||
std::vector<downloading_piece>::const_iterator i
|
||||
|
@ -529,8 +542,10 @@ namespace libtorrent
|
|||
|
||||
bool piece_picker::is_finished(piece_block block) const
|
||||
{
|
||||
assert(block.piece_index >= 0);
|
||||
assert(block.block_index >= 0);
|
||||
assert(block.piece_index < (int)m_piece_map.size());
|
||||
assert(block.block_index < max_blocks_per_piece);
|
||||
assert(block.block_index < (int)max_blocks_per_piece);
|
||||
|
||||
if (m_piece_map[block.piece_index].index == 0xffffff) return true;
|
||||
if (m_piece_map[block.piece_index].downloading == 0) return false;
|
||||
|
@ -546,6 +561,8 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
// integrity_check();
|
||||
#endif
|
||||
assert(block.piece_index >= 0);
|
||||
assert(block.block_index >= 0);
|
||||
assert(block.piece_index < (int)m_piece_map.size());
|
||||
assert(block.block_index < blocks_in_piece(block.piece_index));
|
||||
|
||||
|
@ -580,6 +597,8 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
// integrity_check();
|
||||
#endif
|
||||
assert(block.piece_index >= 0);
|
||||
assert(block.block_index >= 0);
|
||||
assert(block.piece_index < (int)m_piece_map.size());
|
||||
assert(block.block_index < blocks_in_piece(block.piece_index));
|
||||
|
||||
|
@ -615,6 +634,8 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
integrity_check();
|
||||
#endif
|
||||
assert(block.piece_index >= 0);
|
||||
assert(block.block_index >= 0);
|
||||
assert(block.piece_index < m_piece_map.size());
|
||||
assert(block.block_index < blocks_in_piece(block.piece_index));
|
||||
|
||||
|
@ -638,6 +659,7 @@ namespace libtorrent
|
|||
*/
|
||||
void piece_picker::get_downloaders(std::vector<address>& d, int index) const
|
||||
{
|
||||
assert(index >= 0 && index <= (int)m_piece_map.size());
|
||||
std::vector<downloading_piece>::const_iterator i
|
||||
= std::find_if(m_downloads.begin(), m_downloads.end(), has_index(index));
|
||||
assert(i != m_downloads.end());
|
||||
|
@ -675,8 +697,10 @@ namespace libtorrent
|
|||
// integrity_check();
|
||||
#endif
|
||||
|
||||
assert(block.piece_index >= 0);
|
||||
assert(block.block_index >= 0);
|
||||
assert(block.piece_index < (int)m_piece_map.size());
|
||||
assert(block.block_index < max_blocks_per_piece);
|
||||
assert(block.block_index < blocks_in_piece(block.piece_index));
|
||||
|
||||
if (m_piece_map[block.piece_index].downloading == 0)
|
||||
{
|
||||
|
|
|
@ -227,6 +227,7 @@ namespace
|
|||
, torrent::peer_iterator end
|
||||
, size_type free_upload)
|
||||
{
|
||||
assert(free_upload >= 0);
|
||||
if (free_upload <= 0) return free_upload;
|
||||
int num_peers = 0;
|
||||
size_type total_diff = 0;
|
||||
|
@ -296,7 +297,7 @@ namespace libtorrent
|
|||
, m_num_unchoked(0)
|
||||
, m_available_free_upload(0)
|
||||
, m_last_optimistic_disconnect(boost::gregorian::date(1970,boost::gregorian::Jan,1))
|
||||
{}
|
||||
{ assert(t); }
|
||||
// finds the peer that has the worst download rate
|
||||
// and returns it. May return 0 if all peers are
|
||||
// choked.
|
||||
|
@ -742,6 +743,8 @@ namespace libtorrent
|
|||
|
||||
void policy::piece_finished(int index, bool successfully_verified)
|
||||
{
|
||||
assert(index >= 0 && index < m_torrent->torrent_file().num_pieces());
|
||||
|
||||
if (successfully_verified)
|
||||
{
|
||||
// have all peers update their interested-flag
|
||||
|
@ -909,6 +912,7 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
bool policy::has_connection(const peer_connection* c)
|
||||
{
|
||||
assert(c);
|
||||
return std::find_if(
|
||||
m_peers.begin()
|
||||
, m_peers.end()
|
||||
|
|
Loading…
Reference in New Issue