forked from premiere/premiere-libtorrent
*** empty log message ***
This commit is contained in:
parent
23288c74f5
commit
1eaa0877c8
|
@ -61,7 +61,11 @@ namespace libtorrent
|
|||
adler32_crc(): m_adler(adler32(0, 0, 0)) {}
|
||||
|
||||
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; }
|
||||
void reset() { m_adler = adler32(0, 0, 0); }
|
||||
|
||||
|
@ -77,7 +81,11 @@ namespace libtorrent
|
|||
|
||||
hasher() { SHA1Init(&m_context); }
|
||||
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()
|
||||
{
|
||||
|
|
|
@ -255,8 +255,11 @@ namespace libtorrent
|
|||
|
||||
const peer_id& id() const { return m_peer_id; }
|
||||
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
|
||||
{ return m_download_queue; }
|
||||
|
@ -460,7 +463,13 @@ namespace libtorrent
|
|||
// seperately on payload and protocol data.
|
||||
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 length;
|
||||
};
|
||||
|
|
|
@ -62,7 +62,10 @@ 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); }
|
||||
{
|
||||
assert(p_index >= 0);
|
||||
assert(b_index >= 0);
|
||||
}
|
||||
int piece_index;
|
||||
int block_index;
|
||||
bool operator==(const piece_block& b) const
|
||||
|
@ -209,7 +212,10 @@ namespace libtorrent
|
|||
: peer_count(peer_count_)
|
||||
, downloading(0)
|
||||
, index(index_)
|
||||
{ assert(peer_count_>=0); assert(index_>=0); }
|
||||
{
|
||||
assert(peer_count_ >= 0);
|
||||
assert(index_ >= 0);
|
||||
}
|
||||
|
||||
// selects which vector to look in
|
||||
unsigned peer_count : 7;
|
||||
|
@ -267,7 +273,8 @@ namespace libtorrent
|
|||
|
||||
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())
|
||||
return m_blocks_in_last_piece;
|
||||
else
|
||||
|
|
|
@ -205,11 +205,15 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::set_send_quota(int num_bytes)
|
||||
{
|
||||
assert(num_bytes>=0 || num_bytes==-1);
|
||||
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);
|
||||
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_left = num_bytes;
|
||||
|
@ -322,9 +326,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_choke(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
if (m_packet_size != 1)
|
||||
throw protocol_error("'choke' message size != 1");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -356,9 +360,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_unchoke(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
if (m_packet_size != 1)
|
||||
throw protocol_error("'unchoke' message size != 1");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -377,9 +381,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_interested(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
if (m_packet_size != 1)
|
||||
throw protocol_error("'interested' message size != 1");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -398,9 +402,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_not_interested(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
if (m_packet_size != 1)
|
||||
throw protocol_error("'not interested' message size != 1");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -422,9 +426,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_have(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
if (m_packet_size != 5)
|
||||
throw protocol_error("'have' message size != 5");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -467,9 +471,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_bitfield(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
if (m_packet_size - 1 != (m_have_piece.size() + 7) / 8)
|
||||
throw protocol_error("bitfield with invalid size");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -535,9 +539,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_request(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
if (m_packet_size != 13)
|
||||
throw protocol_error("'request' message size != 13");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -603,9 +607,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_piece(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
if (m_recv_pos - received <= 9)
|
||||
{
|
||||
m_last_piece = boost::posix_time::second_clock::local_time();
|
||||
|
@ -751,9 +755,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_cancel(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
if (m_packet_size != 13)
|
||||
throw protocol_error("'cancel' message size != 13");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -789,9 +793,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_extension_list(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
if (m_packet_size > 100 * 1024)
|
||||
{
|
||||
// too big extension message, abort
|
||||
|
@ -840,9 +844,9 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::on_extended(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
m_statistics.received_bytes(0, received);
|
||||
if (m_packet_size < 5)
|
||||
throw protocol_error("'extended' message smaller than 5 bytes");
|
||||
|
@ -916,12 +920,12 @@ namespace libtorrent
|
|||
|
||||
bool peer_connection::dispatch_message(int received)
|
||||
{
|
||||
assert(received>0);
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
assert(m_recv_pos >= received);
|
||||
assert(m_recv_pos > 0);
|
||||
assert(m_torrent);
|
||||
assert(m_torrent != 0);
|
||||
|
||||
int packet_type = m_recv_buffer[0];
|
||||
if (packet_type < 0
|
||||
|
@ -1555,7 +1559,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()
|
||||
&& (m_send_buffer.size() < (unsigned)m_torrent->block_size())
|
||||
&& ((int)m_send_buffer.size() < m_torrent->block_size())
|
||||
&& !m_choked)
|
||||
{
|
||||
peer_request& r = m_requests.front();
|
||||
|
|
|
@ -103,7 +103,8 @@ namespace libtorrent
|
|||
++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);
|
||||
|
||||
int peer_count = m_piece_map[index].peer_count;
|
||||
|
@ -393,7 +394,9 @@ namespace libtorrent
|
|||
|
||||
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 peer_count = m_piece_map[index].peer_count;
|
||||
|
||||
|
|
Loading…
Reference in New Issue