*** empty log message ***
This commit is contained in:
@@ -132,7 +132,7 @@ namespace libtorrent
|
|||||||
template<class InIt>
|
template<class InIt>
|
||||||
std::string read_string(InIt& in, InIt end, int len)
|
std::string read_string(InIt& in, InIt end, int len)
|
||||||
{
|
{
|
||||||
assert(len>=0);
|
assert(len >= 0);
|
||||||
std::string ret;
|
std::string ret;
|
||||||
for (int i = 0; i < len; ++i)
|
for (int i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
|
@@ -61,7 +61,11 @@ namespace libtorrent
|
|||||||
adler32_crc(): m_adler(adler32(0, 0, 0)) {}
|
adler32_crc(): m_adler(adler32(0, 0, 0)) {}
|
||||||
|
|
||||||
void update(const char* data, int len)
|
void update(const char* data, int len)
|
||||||
{ assert(data); assert(len>0); m_adler = adler32(m_adler, data, len); }
|
{
|
||||||
|
assert(data != 0);
|
||||||
|
assert(len > 0);
|
||||||
|
m_adler = adler32(m_adler, data, len);
|
||||||
|
}
|
||||||
unsigned long final() const { return m_adler; }
|
unsigned long final() const { return m_adler; }
|
||||||
void reset() { m_adler = adler32(0, 0, 0); }
|
void reset() { m_adler = adler32(0, 0, 0); }
|
||||||
|
|
||||||
@@ -77,7 +81,11 @@ namespace libtorrent
|
|||||||
|
|
||||||
hasher() { SHA1Init(&m_context); }
|
hasher() { SHA1Init(&m_context); }
|
||||||
void update(const char* data, int 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); }
|
{
|
||||||
|
assert(data != 0);
|
||||||
|
assert(len > 0);
|
||||||
|
SHA1Update(&m_context, reinterpret_cast<unsigned char*>(const_cast<char*>(data)), len);
|
||||||
|
}
|
||||||
|
|
||||||
sha1_hash final()
|
sha1_hash final()
|
||||||
{
|
{
|
||||||
|
@@ -255,8 +255,11 @@ namespace libtorrent
|
|||||||
|
|
||||||
const peer_id& id() const { return m_peer_id; }
|
const peer_id& id() const { return m_peer_id; }
|
||||||
bool has_piece(int i) const
|
bool has_piece(int i) const
|
||||||
{ assert(i >= 0 && i < m_torrent->torrent_file().num_pieces());
|
{
|
||||||
return m_have_piece[i]; }
|
assert(i >= 0);
|
||||||
|
assert(i < m_torrent->torrent_file().num_pieces());
|
||||||
|
return m_have_piece[i];
|
||||||
|
}
|
||||||
|
|
||||||
const std::deque<piece_block>& download_queue() const
|
const std::deque<piece_block>& download_queue() const
|
||||||
{ return m_download_queue; }
|
{ return m_download_queue; }
|
||||||
@@ -460,7 +463,13 @@ namespace libtorrent
|
|||||||
// seperately on payload and protocol data.
|
// seperately on payload and protocol data.
|
||||||
struct range
|
struct range
|
||||||
{
|
{
|
||||||
range(int s, int l): start(s), length(l) { assert(s>=0); assert(l>0);}
|
range(int s, int l)
|
||||||
|
: start(s)
|
||||||
|
, length(l)
|
||||||
|
{
|
||||||
|
assert(s >= 0);
|
||||||
|
assert(l > 0);
|
||||||
|
}
|
||||||
int start;
|
int start;
|
||||||
int length;
|
int length;
|
||||||
};
|
};
|
||||||
|
@@ -62,7 +62,10 @@ namespace libtorrent
|
|||||||
piece_block(int p_index, int b_index)
|
piece_block(int p_index, int b_index)
|
||||||
: piece_index(p_index)
|
: piece_index(p_index)
|
||||||
, block_index(b_index)
|
, block_index(b_index)
|
||||||
{ assert(p_index>=0); assert(b_index>=0); }
|
{
|
||||||
|
assert(p_index >= 0);
|
||||||
|
assert(b_index >= 0);
|
||||||
|
}
|
||||||
int piece_index;
|
int piece_index;
|
||||||
int block_index;
|
int block_index;
|
||||||
bool operator==(const piece_block& b) const
|
bool operator==(const piece_block& b) const
|
||||||
@@ -191,7 +194,7 @@ namespace libtorrent
|
|||||||
// functor that compares indices on downloading_pieces
|
// functor that compares indices on downloading_pieces
|
||||||
struct has_index
|
struct has_index
|
||||||
{
|
{
|
||||||
has_index(int i): index(i) { assert(i>=0); }
|
has_index(int i): index(i) { assert(i >= 0); }
|
||||||
bool operator()(const downloading_piece& p) const
|
bool operator()(const downloading_piece& p) const
|
||||||
{ return p.index == index; }
|
{ return p.index == index; }
|
||||||
int index;
|
int index;
|
||||||
@@ -209,7 +212,10 @@ namespace libtorrent
|
|||||||
: peer_count(peer_count_)
|
: peer_count(peer_count_)
|
||||||
, downloading(0)
|
, downloading(0)
|
||||||
, index(index_)
|
, index(index_)
|
||||||
{ assert(peer_count_>=0); assert(index_>=0); }
|
{
|
||||||
|
assert(peer_count_ >= 0);
|
||||||
|
assert(index_ >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
// selects which vector to look in
|
// selects which vector to look in
|
||||||
unsigned peer_count : 7;
|
unsigned peer_count : 7;
|
||||||
@@ -267,7 +273,8 @@ namespace libtorrent
|
|||||||
|
|
||||||
inline int piece_picker::blocks_in_piece(int index) const
|
inline int piece_picker::blocks_in_piece(int index) const
|
||||||
{
|
{
|
||||||
assert(index>=0 && (unsigned)index < m_piece_map.size());
|
assert(index >= 0);
|
||||||
|
assert(index < (int)m_piece_map.size());
|
||||||
if (index+1 == m_piece_map.size())
|
if (index+1 == m_piece_map.size())
|
||||||
return m_blocks_in_last_piece;
|
return m_blocks_in_last_piece;
|
||||||
else
|
else
|
||||||
|
@@ -205,11 +205,15 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::set_send_quota(int num_bytes)
|
void peer_connection::set_send_quota(int num_bytes)
|
||||||
{
|
{
|
||||||
assert(num_bytes>=0 || num_bytes==-1);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(num_bytes >= 0 || num_bytes == -1);
|
||||||
|
|
||||||
|
if (num_bytes > m_send_quota_limit
|
||||||
|
&& m_send_quota_limit != -1)
|
||||||
|
num_bytes = m_send_quota_limit;
|
||||||
|
|
||||||
assert(num_bytes <= m_send_quota_limit || m_send_quota_limit == -1);
|
assert(num_bytes <= m_send_quota_limit || m_send_quota_limit == -1);
|
||||||
if (num_bytes > m_send_quota_limit && m_send_quota_limit!=-1) num_bytes = m_send_quota_limit;
|
|
||||||
|
|
||||||
m_send_quota = num_bytes;
|
m_send_quota = num_bytes;
|
||||||
m_send_quota_left = num_bytes;
|
m_send_quota_left = num_bytes;
|
||||||
@@ -322,9 +326,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_choke(int received)
|
void peer_connection::on_choke(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
if (m_packet_size != 1)
|
if (m_packet_size != 1)
|
||||||
throw protocol_error("'choke' message size != 1");
|
throw protocol_error("'choke' message size != 1");
|
||||||
m_statistics.received_bytes(0, received);
|
m_statistics.received_bytes(0, received);
|
||||||
@@ -356,9 +360,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_unchoke(int received)
|
void peer_connection::on_unchoke(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
if (m_packet_size != 1)
|
if (m_packet_size != 1)
|
||||||
throw protocol_error("'unchoke' message size != 1");
|
throw protocol_error("'unchoke' message size != 1");
|
||||||
m_statistics.received_bytes(0, received);
|
m_statistics.received_bytes(0, received);
|
||||||
@@ -377,9 +381,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_interested(int received)
|
void peer_connection::on_interested(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
if (m_packet_size != 1)
|
if (m_packet_size != 1)
|
||||||
throw protocol_error("'interested' message size != 1");
|
throw protocol_error("'interested' message size != 1");
|
||||||
m_statistics.received_bytes(0, received);
|
m_statistics.received_bytes(0, received);
|
||||||
@@ -398,9 +402,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_not_interested(int received)
|
void peer_connection::on_not_interested(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
if (m_packet_size != 1)
|
if (m_packet_size != 1)
|
||||||
throw protocol_error("'not interested' message size != 1");
|
throw protocol_error("'not interested' message size != 1");
|
||||||
m_statistics.received_bytes(0, received);
|
m_statistics.received_bytes(0, received);
|
||||||
@@ -422,9 +426,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_have(int received)
|
void peer_connection::on_have(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
if (m_packet_size != 5)
|
if (m_packet_size != 5)
|
||||||
throw protocol_error("'have' message size != 5");
|
throw protocol_error("'have' message size != 5");
|
||||||
m_statistics.received_bytes(0, received);
|
m_statistics.received_bytes(0, received);
|
||||||
@@ -467,9 +471,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_bitfield(int received)
|
void peer_connection::on_bitfield(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
if (m_packet_size - 1 != (m_have_piece.size() + 7) / 8)
|
if (m_packet_size - 1 != (m_have_piece.size() + 7) / 8)
|
||||||
throw protocol_error("bitfield with invalid size");
|
throw protocol_error("bitfield with invalid size");
|
||||||
m_statistics.received_bytes(0, received);
|
m_statistics.received_bytes(0, received);
|
||||||
@@ -535,9 +539,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_request(int received)
|
void peer_connection::on_request(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
if (m_packet_size != 13)
|
if (m_packet_size != 13)
|
||||||
throw protocol_error("'request' message size != 13");
|
throw protocol_error("'request' message size != 13");
|
||||||
m_statistics.received_bytes(0, received);
|
m_statistics.received_bytes(0, received);
|
||||||
@@ -603,9 +607,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_piece(int received)
|
void peer_connection::on_piece(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
if (m_recv_pos - received <= 9)
|
if (m_recv_pos - received <= 9)
|
||||||
{
|
{
|
||||||
m_last_piece = boost::posix_time::second_clock::local_time();
|
m_last_piece = boost::posix_time::second_clock::local_time();
|
||||||
@@ -751,9 +755,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_cancel(int received)
|
void peer_connection::on_cancel(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
if (m_packet_size != 13)
|
if (m_packet_size != 13)
|
||||||
throw protocol_error("'cancel' message size != 13");
|
throw protocol_error("'cancel' message size != 13");
|
||||||
m_statistics.received_bytes(0, received);
|
m_statistics.received_bytes(0, received);
|
||||||
@@ -789,9 +793,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_extension_list(int received)
|
void peer_connection::on_extension_list(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
if (m_packet_size > 100 * 1024)
|
if (m_packet_size > 100 * 1024)
|
||||||
{
|
{
|
||||||
// too big extension message, abort
|
// too big extension message, abort
|
||||||
@@ -840,9 +844,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void peer_connection::on_extended(int received)
|
void peer_connection::on_extended(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
m_statistics.received_bytes(0, received);
|
m_statistics.received_bytes(0, received);
|
||||||
if (m_packet_size < 5)
|
if (m_packet_size < 5)
|
||||||
throw protocol_error("'extended' message smaller than 5 bytes");
|
throw protocol_error("'extended' message smaller than 5 bytes");
|
||||||
@@ -916,12 +920,12 @@ namespace libtorrent
|
|||||||
|
|
||||||
bool peer_connection::dispatch_message(int received)
|
bool peer_connection::dispatch_message(int received)
|
||||||
{
|
{
|
||||||
assert(received>0);
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
assert(received > 0);
|
||||||
assert(m_recv_pos >= received);
|
assert(m_recv_pos >= received);
|
||||||
assert(m_recv_pos > 0);
|
assert(m_recv_pos > 0);
|
||||||
assert(m_torrent);
|
assert(m_torrent != 0);
|
||||||
|
|
||||||
int packet_type = m_recv_buffer[0];
|
int packet_type = m_recv_buffer[0];
|
||||||
if (packet_type < 0
|
if (packet_type < 0
|
||||||
@@ -1555,7 +1559,7 @@ namespace libtorrent
|
|||||||
// requested block. Have a limit of how much of the requested
|
// requested block. Have a limit of how much of the requested
|
||||||
// block is actually read at a time.
|
// block is actually read at a time.
|
||||||
while (!m_requests.empty()
|
while (!m_requests.empty()
|
||||||
&& (m_send_buffer.size() < (unsigned)m_torrent->block_size())
|
&& ((int)m_send_buffer.size() < m_torrent->block_size())
|
||||||
&& !m_choked)
|
&& !m_choked)
|
||||||
{
|
{
|
||||||
peer_request& r = m_requests.front();
|
peer_request& r = m_requests.front();
|
||||||
|
@@ -59,8 +59,8 @@ namespace libtorrent
|
|||||||
, m_downloading_piece_info(2)
|
, m_downloading_piece_info(2)
|
||||||
, m_piece_map((total_num_blocks + blocks_per_piece-1) / blocks_per_piece)
|
, m_piece_map((total_num_blocks + blocks_per_piece-1) / blocks_per_piece)
|
||||||
{
|
{
|
||||||
assert(blocks_per_piece>0);
|
assert(blocks_per_piece > 0);
|
||||||
assert(total_num_blocks>0);
|
assert(total_num_blocks > 0);
|
||||||
|
|
||||||
m_blocks_per_piece = blocks_per_piece;
|
m_blocks_per_piece = blocks_per_piece;
|
||||||
m_blocks_in_last_piece = total_num_blocks % blocks_per_piece;
|
m_blocks_in_last_piece = total_num_blocks % blocks_per_piece;
|
||||||
@@ -103,7 +103,8 @@ namespace libtorrent
|
|||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
int index = *i;
|
int index = *i;
|
||||||
assert(index >= 0 && index < (int)m_piece_map.size());
|
assert(index >= 0);
|
||||||
|
assert(index < (int)m_piece_map.size());
|
||||||
assert(m_piece_map[index].index == 0xffffff);
|
assert(m_piece_map[index].index == 0xffffff);
|
||||||
|
|
||||||
int peer_count = m_piece_map[index].peer_count;
|
int peer_count = m_piece_map[index].peer_count;
|
||||||
@@ -393,7 +394,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
void piece_picker::we_have(int index)
|
void piece_picker::we_have(int index)
|
||||||
{
|
{
|
||||||
assert(index >= 0 && index < (int)m_piece_map.size());
|
assert(index >= 0);
|
||||||
|
assert(index < (int)m_piece_map.size());
|
||||||
|
|
||||||
int info_index = m_piece_map[index].index;
|
int info_index = m_piece_map[index].index;
|
||||||
int peer_count = m_piece_map[index].peer_count;
|
int peer_count = m_piece_map[index].peer_count;
|
||||||
|
|
||||||
@@ -410,7 +413,7 @@ namespace libtorrent
|
|||||||
std::vector<piece_block>& interesting_pieces,
|
std::vector<piece_block>& interesting_pieces,
|
||||||
int num_blocks) const
|
int num_blocks) const
|
||||||
{
|
{
|
||||||
assert(num_blocks>0);
|
assert(num_blocks > 0);
|
||||||
assert(pieces.size() == m_piece_map.size());
|
assert(pieces.size() == m_piece_map.size());
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@@ -452,7 +455,7 @@ namespace libtorrent
|
|||||||
std::vector<piece_block>& interesting_blocks,
|
std::vector<piece_block>& interesting_blocks,
|
||||||
int num_blocks) const
|
int num_blocks) const
|
||||||
{
|
{
|
||||||
assert(num_blocks>0);
|
assert(num_blocks > 0);
|
||||||
|
|
||||||
for (std::vector<int>::const_iterator i = piece_list.begin();
|
for (std::vector<int>::const_iterator i = piece_list.begin();
|
||||||
i != piece_list.end();
|
i != piece_list.end();
|
||||||
|
Reference in New Issue
Block a user