lt sync 1649
This commit is contained in:
parent
d240ba3c01
commit
94fd3c0f37
|
@ -115,7 +115,7 @@ namespace libtorrent
|
|||
, std::string const& msg)
|
||||
: torrent_alert(h, alert::info, msg)
|
||||
, piece_index(index)
|
||||
{ assert(index >= 0);}
|
||||
{ TORRENT_ASSERT(index >= 0);}
|
||||
|
||||
virtual std::auto_ptr<alert> clone() const
|
||||
{ return std::auto_ptr<alert>(new hash_failed_alert(*this)); }
|
||||
|
@ -193,7 +193,7 @@ namespace libtorrent
|
|||
, const std::string& msg)
|
||||
: torrent_alert(h, alert::debug, msg)
|
||||
, piece_index(piece_num)
|
||||
{ assert(piece_index >= 0);}
|
||||
{ TORRENT_ASSERT(piece_index >= 0);}
|
||||
|
||||
int piece_index;
|
||||
|
||||
|
@ -211,7 +211,7 @@ namespace libtorrent
|
|||
: torrent_alert(h, alert::debug, msg)
|
||||
, block_index(block_num)
|
||||
, piece_index(piece_num)
|
||||
{ assert(block_index >= 0 && piece_index >= 0);}
|
||||
{ TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
|
||||
|
||||
int block_index;
|
||||
int piece_index;
|
||||
|
@ -232,7 +232,7 @@ namespace libtorrent
|
|||
, peer_speedmsg(speedmsg)
|
||||
, block_index(block_num)
|
||||
, piece_index(piece_num)
|
||||
{ assert(block_index >= 0 && piece_index >= 0);}
|
||||
{ TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
|
||||
|
||||
std::string peer_speedmsg;
|
||||
int block_index;
|
||||
|
|
|
@ -30,25 +30,19 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#if (defined __linux__ || defined __MACH__) && defined __GNUC__
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#ifndef TORRENT_ASSERT
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
#include <cassert>
|
||||
|
||||
#if (defined __linux__ || defined __MACH__) && defined __GNUC__ && !defined(NDEBUG)
|
||||
|
||||
TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file, char const* function);
|
||||
|
||||
#define assert(x) if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__)
|
||||
|
||||
#endif
|
||||
#define TORRENT_ASSERT(x) if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__)
|
||||
|
||||
#else
|
||||
#ifndef assert
|
||||
#define assert(x) (void)
|
||||
#endif
|
||||
#define TORRENT_ASSERT(x) assert(x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ namespace libtorrent
|
|||
void unchoke_peer(peer_connection& c)
|
||||
{
|
||||
torrent* t = c.associated_torrent().lock().get();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
if (t->unchoke_peer(c))
|
||||
++m_num_unchoked;
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ namespace libtorrent
|
|||
send_buffer_capacity += i->second->send_buffer_capacity();
|
||||
used_send_buffer += i->second->send_buffer_size();
|
||||
}
|
||||
assert(send_buffer_capacity >= used_send_buffer);
|
||||
TORRENT_ASSERT(send_buffer_capacity >= used_send_buffer);
|
||||
m_buffer_usage_logger << log_time() << " send_buffer_size: " << send_buffer_capacity << std::endl;
|
||||
m_buffer_usage_logger << log_time() << " used_send_buffer: " << used_send_buffer << std::endl;
|
||||
m_buffer_usage_logger << log_time() << " send_buffer_utilization: "
|
||||
|
|
|
@ -111,14 +111,14 @@ struct bandwidth_limit
|
|||
|
||||
void assign(int amount) throw()
|
||||
{
|
||||
assert(amount > 0);
|
||||
TORRENT_ASSERT(amount > 0);
|
||||
m_current_rate += amount;
|
||||
m_quota_left += amount;
|
||||
}
|
||||
|
||||
void use_quota(int amount) throw()
|
||||
{
|
||||
assert(amount <= m_quota_left);
|
||||
TORRENT_ASSERT(amount <= m_quota_left);
|
||||
m_quota_left -= amount;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ struct bandwidth_limit
|
|||
|
||||
void expire(int amount) throw()
|
||||
{
|
||||
assert(amount >= 0);
|
||||
TORRENT_ASSERT(amount >= 0);
|
||||
m_current_rate -= amount;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ private:
|
|||
template<class T>
|
||||
T clamp(T val, T ceiling, T floor) throw()
|
||||
{
|
||||
assert(ceiling >= floor);
|
||||
TORRENT_ASSERT(ceiling >= floor);
|
||||
if (val >= ceiling) return ceiling;
|
||||
else if (val <= floor) return floor;
|
||||
return val;
|
||||
|
@ -186,7 +186,7 @@ struct bandwidth_manager
|
|||
void throttle(int limit) throw()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
assert(limit >= 0);
|
||||
TORRENT_ASSERT(limit >= 0);
|
||||
m_limit = limit;
|
||||
}
|
||||
|
||||
|
@ -204,9 +204,9 @@ struct bandwidth_manager
|
|||
, bool non_prioritized) throw()
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
assert(blk > 0);
|
||||
TORRENT_ASSERT(blk > 0);
|
||||
|
||||
assert(!peer->ignore_bandwidth_limits());
|
||||
TORRENT_ASSERT(!peer->ignore_bandwidth_limits());
|
||||
|
||||
// make sure this peer isn't already in line
|
||||
// waiting for bandwidth
|
||||
|
@ -214,11 +214,11 @@ struct bandwidth_manager
|
|||
for (typename queue_t::iterator i = m_queue.begin()
|
||||
, end(m_queue.end()); i != end; ++i)
|
||||
{
|
||||
assert(i->peer < peer || peer < i->peer);
|
||||
TORRENT_ASSERT(i->peer < peer || peer < i->peer);
|
||||
}
|
||||
#endif
|
||||
|
||||
assert(peer->max_assignable_bandwidth(m_channel) > 0);
|
||||
TORRENT_ASSERT(peer->max_assignable_bandwidth(m_channel) > 0);
|
||||
boost::shared_ptr<Torrent> t = peer->associated_torrent().lock();
|
||||
m_queue.push_back(bw_queue_entry<PeerConnection>(peer, blk, non_prioritized));
|
||||
if (!non_prioritized)
|
||||
|
@ -257,7 +257,7 @@ struct bandwidth_manager
|
|||
current_quota += i->amount;
|
||||
}
|
||||
|
||||
assert(current_quota == m_current_quota);
|
||||
TORRENT_ASSERT(current_quota == m_current_quota);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -279,7 +279,7 @@ private:
|
|||
m_history_timer.async_wait(bind(&bandwidth_manager::on_history_expire, this, _1));
|
||||
#ifndef NDEBUG
|
||||
}
|
||||
catch (std::exception&) { assert(false); }
|
||||
catch (std::exception&) { TORRENT_ASSERT(false); }
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ private:
|
|||
|
||||
if (e) return;
|
||||
|
||||
assert(!m_history.empty());
|
||||
TORRENT_ASSERT(!m_history.empty());
|
||||
|
||||
ptime now(time_now());
|
||||
while (!m_history.empty() && m_history.back().expires_at <= now)
|
||||
|
@ -300,7 +300,7 @@ private:
|
|||
history_entry<PeerConnection, Torrent> e = m_history.back();
|
||||
m_history.pop_back();
|
||||
m_current_quota -= e.amount;
|
||||
assert(m_current_quota >= 0);
|
||||
TORRENT_ASSERT(m_current_quota >= 0);
|
||||
intrusive_ptr<PeerConnection> c = e.peer;
|
||||
shared_ptr<Torrent> t = e.tor.lock();
|
||||
if (!c->is_disconnecting()) c->expire_bandwidth(m_channel, e.amount);
|
||||
|
@ -322,7 +322,7 @@ private:
|
|||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -356,9 +356,9 @@ private:
|
|||
|
||||
while (!m_queue.empty() && amount > 0)
|
||||
{
|
||||
assert(amount == limit - m_current_quota);
|
||||
TORRENT_ASSERT(amount == limit - m_current_quota);
|
||||
bw_queue_entry<PeerConnection> qe = m_queue.front();
|
||||
assert(qe.max_block_size > 0);
|
||||
TORRENT_ASSERT(qe.max_block_size > 0);
|
||||
m_queue.pop_front();
|
||||
|
||||
shared_ptr<Torrent> t = qe.peer->associated_torrent().lock();
|
||||
|
@ -366,7 +366,7 @@ private:
|
|||
if (qe.peer->is_disconnecting())
|
||||
{
|
||||
t->expire_bandwidth(m_channel, qe.max_block_size);
|
||||
assert(amount == limit - m_current_quota);
|
||||
TORRENT_ASSERT(amount == limit - m_current_quota);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ private:
|
|||
if (max_assignable == 0)
|
||||
{
|
||||
t->expire_bandwidth(m_channel, qe.max_block_size);
|
||||
assert(amount == limit - m_current_quota);
|
||||
TORRENT_ASSERT(amount == limit - m_current_quota);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -434,20 +434,20 @@ private:
|
|||
// than the max_bandwidth_block_size
|
||||
int hand_out_amount = (std::min)((std::min)(block_size, max_assignable)
|
||||
, amount);
|
||||
assert(hand_out_amount > 0);
|
||||
assert(amount == limit - m_current_quota);
|
||||
TORRENT_ASSERT(hand_out_amount > 0);
|
||||
TORRENT_ASSERT(amount == limit - m_current_quota);
|
||||
amount -= hand_out_amount;
|
||||
assert(hand_out_amount <= qe.max_block_size);
|
||||
TORRENT_ASSERT(hand_out_amount <= qe.max_block_size);
|
||||
t->assign_bandwidth(m_channel, hand_out_amount, qe.max_block_size);
|
||||
qe.peer->assign_bandwidth(m_channel, hand_out_amount);
|
||||
add_history_entry(history_entry<PeerConnection, Torrent>(
|
||||
qe.peer, t, hand_out_amount, now + bw_window_size));
|
||||
assert(amount == limit - m_current_quota);
|
||||
TORRENT_ASSERT(amount == limit - m_current_quota);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{ assert(false); };
|
||||
{ TORRENT_ASSERT(false); };
|
||||
#endif
|
||||
m_in_hand_out_bandwidth = false;
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace libtorrent
|
|||
template<class InIt>
|
||||
void read_string(InIt& in, InIt end, int len, std::string& str)
|
||||
{
|
||||
assert(len >= 0);
|
||||
TORRENT_ASSERT(len >= 0);
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
if (in == end) throw invalid_encoding();
|
||||
|
@ -214,7 +214,7 @@ namespace libtorrent
|
|||
{
|
||||
++in; // 'i'
|
||||
std::string val = read_until(in, end, 'e');
|
||||
assert(*in == 'e');
|
||||
TORRENT_ASSERT(*in == 'e');
|
||||
++in; // 'e'
|
||||
ret = entry(entry::int_t);
|
||||
ret.integer() = boost::lexical_cast<entry::integer_type>(val);
|
||||
|
@ -233,7 +233,7 @@ namespace libtorrent
|
|||
bdecode_recursive(in, end, e);
|
||||
if (in == end) throw invalid_encoding();
|
||||
}
|
||||
assert(*in == 'e');
|
||||
TORRENT_ASSERT(*in == 'e');
|
||||
++in; // 'e'
|
||||
} break;
|
||||
|
||||
|
@ -251,7 +251,7 @@ namespace libtorrent
|
|||
bdecode_recursive(in, end, e);
|
||||
if (in == end) throw invalid_encoding();
|
||||
}
|
||||
assert(*in == 'e');
|
||||
TORRENT_ASSERT(*in == 'e');
|
||||
++in; // 'e'
|
||||
} break;
|
||||
|
||||
|
@ -261,7 +261,7 @@ namespace libtorrent
|
|||
if (isdigit((unsigned char)*in))
|
||||
{
|
||||
std::string len_s = read_until(in, end, ':');
|
||||
assert(*in == ':');
|
||||
TORRENT_ASSERT(*in == ':');
|
||||
++in; // ':'
|
||||
int len = std::atoi(len_s.c_str());
|
||||
ret = entry(entry::string_t);
|
||||
|
|
|
@ -342,8 +342,8 @@ namespace libtorrent
|
|||
: start(s)
|
||||
, length(l)
|
||||
{
|
||||
assert(s >= 0);
|
||||
assert(l > 0);
|
||||
TORRENT_ASSERT(s >= 0);
|
||||
TORRENT_ASSERT(l > 0);
|
||||
}
|
||||
int start;
|
||||
int length;
|
||||
|
|
|
@ -51,11 +51,11 @@ public:
|
|||
|
||||
char operator[](int index) const
|
||||
{
|
||||
assert(begin + index < end);
|
||||
TORRENT_ASSERT(begin + index < end);
|
||||
return begin[index];
|
||||
}
|
||||
|
||||
int left() const { assert(end >= begin); return end - begin; }
|
||||
int left() const { TORRENT_ASSERT(end >= begin); return end - begin; }
|
||||
|
||||
char* begin;
|
||||
char* end;
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
char operator[](int index) const
|
||||
{
|
||||
assert(begin + index < end);
|
||||
TORRENT_ASSERT(begin + index < end);
|
||||
return begin[index];
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
&& end == p_interval.end);
|
||||
}
|
||||
|
||||
int left() const { assert(end >= begin); return end - begin; }
|
||||
int left() const { TORRENT_ASSERT(end >= begin); return end - begin; }
|
||||
|
||||
char const* begin;
|
||||
char const* end;
|
||||
|
@ -142,9 +142,9 @@ public:
|
|||
|
||||
void erase(char* begin, char* end)
|
||||
{
|
||||
assert(end <= m_end);
|
||||
assert(begin >= m_begin);
|
||||
assert(begin <= end);
|
||||
TORRENT_ASSERT(end <= m_end);
|
||||
TORRENT_ASSERT(begin >= m_begin);
|
||||
TORRENT_ASSERT(begin <= end);
|
||||
if (end == m_end)
|
||||
{
|
||||
resize(begin - m_begin);
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
void reserve(std::size_t n)
|
||||
{
|
||||
if (n <= capacity()) return;
|
||||
assert(n > 0);
|
||||
TORRENT_ASSERT(n > 0);
|
||||
|
||||
char* buf = (char*)::operator new(n);
|
||||
std::size_t s = size();
|
||||
|
@ -172,8 +172,8 @@ public:
|
|||
}
|
||||
|
||||
bool empty() const { return m_begin == m_end; }
|
||||
char& operator[](std::size_t i) { assert(i >= 0 && i < size()); return m_begin[i]; }
|
||||
char const& operator[](std::size_t i) const { assert(i >= 0 && i < size()); return m_begin[i]; }
|
||||
char& operator[](std::size_t i) { TORRENT_ASSERT(i >= 0 && i < size()); return m_begin[i]; }
|
||||
char const& operator[](std::size_t i) const { TORRENT_ASSERT(i >= 0 && i < size()); return m_begin[i]; }
|
||||
|
||||
char* begin() { return m_begin; }
|
||||
char const* begin() const { return m_begin; }
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace libtorrent
|
|||
|
||||
void pop_front(int bytes_to_pop)
|
||||
{
|
||||
assert(bytes_to_pop <= m_bytes);
|
||||
TORRENT_ASSERT(bytes_to_pop <= m_bytes);
|
||||
while (bytes_to_pop > 0 && !m_vec.empty())
|
||||
{
|
||||
buffer_t& b = m_vec.front();
|
||||
|
@ -69,9 +69,9 @@ namespace libtorrent
|
|||
b.start += bytes_to_pop;
|
||||
b.used_size -= bytes_to_pop;
|
||||
m_bytes -= bytes_to_pop;
|
||||
assert(m_bytes <= m_capacity);
|
||||
assert(m_bytes >= 0);
|
||||
assert(m_capacity >= 0);
|
||||
TORRENT_ASSERT(m_bytes <= m_capacity);
|
||||
TORRENT_ASSERT(m_bytes >= 0);
|
||||
TORRENT_ASSERT(m_capacity >= 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -79,9 +79,9 @@ namespace libtorrent
|
|||
m_bytes -= b.used_size;
|
||||
m_capacity -= b.size;
|
||||
bytes_to_pop -= b.used_size;
|
||||
assert(m_bytes >= 0);
|
||||
assert(m_capacity >= 0);
|
||||
assert(m_bytes <= m_capacity);
|
||||
TORRENT_ASSERT(m_bytes >= 0);
|
||||
TORRENT_ASSERT(m_capacity >= 0);
|
||||
TORRENT_ASSERT(m_bytes <= m_capacity);
|
||||
m_vec.pop_front();
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace libtorrent
|
|||
template <class D>
|
||||
void append_buffer(char* buffer, int size, int used_size, D const& destructor)
|
||||
{
|
||||
assert(size >= used_size);
|
||||
TORRENT_ASSERT(size >= used_size);
|
||||
buffer_t b;
|
||||
b.buf = buffer;
|
||||
b.size = size;
|
||||
|
@ -100,7 +100,7 @@ namespace libtorrent
|
|||
|
||||
m_bytes += used_size;
|
||||
m_capacity += size;
|
||||
assert(m_bytes <= m_capacity);
|
||||
TORRENT_ASSERT(m_bytes <= m_capacity);
|
||||
}
|
||||
|
||||
// returns the number of bytes available at the
|
||||
|
@ -134,7 +134,7 @@ namespace libtorrent
|
|||
if (insert + size > b.buf + b.size) return 0;
|
||||
b.used_size += size;
|
||||
m_bytes += size;
|
||||
assert(m_bytes <= m_capacity);
|
||||
TORRENT_ASSERT(m_bytes <= m_capacity);
|
||||
return insert;
|
||||
}
|
||||
|
||||
|
@ -147,11 +147,11 @@ namespace libtorrent
|
|||
{
|
||||
if (i->used_size > to_send)
|
||||
{
|
||||
assert(to_send > 0);
|
||||
TORRENT_ASSERT(to_send > 0);
|
||||
m_tmp_vec.push_back(asio::const_buffer(i->start, to_send));
|
||||
break;
|
||||
}
|
||||
assert(i->used_size > 0);
|
||||
TORRENT_ASSERT(i->used_size > 0);
|
||||
m_tmp_vec.push_back(asio::const_buffer(i->start, i->used_size));
|
||||
to_send -= i->used_size;
|
||||
}
|
||||
|
|
|
@ -50,12 +50,12 @@ namespace libtorrent
|
|||
, revision_version(revision)
|
||||
, tag_version(tag)
|
||||
{
|
||||
assert(id_string);
|
||||
assert(major >= 0);
|
||||
assert(minor >= 0);
|
||||
assert(revision >= 0);
|
||||
assert(tag >= 0);
|
||||
assert(std::strlen(id_string) == 2);
|
||||
TORRENT_ASSERT(id_string);
|
||||
TORRENT_ASSERT(major >= 0);
|
||||
TORRENT_ASSERT(minor >= 0);
|
||||
TORRENT_ASSERT(revision >= 0);
|
||||
TORRENT_ASSERT(tag >= 0);
|
||||
TORRENT_ASSERT(std::strlen(id_string) == 2);
|
||||
name[0] = id_string[0];
|
||||
name[1] = id_string[1];
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ namespace libtorrent
|
|||
{
|
||||
if (v >= 0 && v < 10) return '0' + v;
|
||||
else if (v >= 10) return 'A' + (v - 10);
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
return '0';
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ namespace libtorrent
|
|||
|
||||
void update(const char* data, int len)
|
||||
{
|
||||
assert(data != 0);
|
||||
assert(len > 0);
|
||||
TORRENT_ASSERT(data != 0);
|
||||
TORRENT_ASSERT(len > 0);
|
||||
m_adler = adler32(m_adler, (const Bytef*)data, len);
|
||||
}
|
||||
unsigned long final() const { return m_adler; }
|
||||
|
@ -91,14 +91,14 @@ namespace libtorrent
|
|||
hasher(const char* data, int len)
|
||||
{
|
||||
SHA1_Init(&m_context);
|
||||
assert(data != 0);
|
||||
assert(len > 0);
|
||||
TORRENT_ASSERT(data != 0);
|
||||
TORRENT_ASSERT(len > 0);
|
||||
SHA1_Update(&m_context, reinterpret_cast<unsigned char const*>(data), len);
|
||||
}
|
||||
void update(const char* data, int len)
|
||||
{
|
||||
assert(data != 0);
|
||||
assert(len > 0);
|
||||
TORRENT_ASSERT(data != 0);
|
||||
TORRENT_ASSERT(len > 0);
|
||||
SHA1_Update(&m_context, reinterpret_cast<unsigned char const*>(data), len);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ struct http_connection : boost::enable_shared_from_this<http_connection>, boost:
|
|||
, m_connection_ticket(-1)
|
||||
, m_cc(cc)
|
||||
{
|
||||
assert(!m_handler.empty());
|
||||
TORRENT_ASSERT(!m_handler.empty());
|
||||
}
|
||||
|
||||
void rate_limit(int limit);
|
||||
|
|
|
@ -49,15 +49,15 @@ namespace libtorrent
|
|||
|
||||
friend void intrusive_ptr_add_ref(intrusive_ptr_base<T> const* s)
|
||||
{
|
||||
assert(s->m_refs >= 0);
|
||||
assert(s != 0);
|
||||
TORRENT_ASSERT(s->m_refs >= 0);
|
||||
TORRENT_ASSERT(s != 0);
|
||||
++s->m_refs;
|
||||
}
|
||||
|
||||
friend void intrusive_ptr_release(intrusive_ptr_base<T> const* s)
|
||||
{
|
||||
assert(s->m_refs > 0);
|
||||
assert(s != 0);
|
||||
TORRENT_ASSERT(s->m_refs > 0);
|
||||
TORRENT_ASSERT(s != 0);
|
||||
if (--s->m_refs == 0)
|
||||
delete static_cast<T const*>(s);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace libtorrent
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace libtorrent
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -156,16 +156,16 @@ namespace detail
|
|||
using boost::next;
|
||||
using boost::prior;
|
||||
|
||||
assert(!m_access_list.empty());
|
||||
assert(first < last || first == last);
|
||||
TORRENT_ASSERT(!m_access_list.empty());
|
||||
TORRENT_ASSERT(first < last || first == last);
|
||||
|
||||
typename range_t::iterator i = m_access_list.upper_bound(first);
|
||||
typename range_t::iterator j = m_access_list.upper_bound(last);
|
||||
|
||||
if (i != m_access_list.begin()) --i;
|
||||
|
||||
assert(j != m_access_list.begin());
|
||||
assert(j != i);
|
||||
TORRENT_ASSERT(j != m_access_list.begin());
|
||||
TORRENT_ASSERT(j != i);
|
||||
|
||||
int first_access = i->access;
|
||||
int last_access = prior(j)->access;
|
||||
|
@ -179,8 +179,8 @@ namespace detail
|
|||
--i;
|
||||
first_access = i->access;
|
||||
}
|
||||
assert(!m_access_list.empty());
|
||||
assert(i != m_access_list.end());
|
||||
TORRENT_ASSERT(!m_access_list.empty());
|
||||
TORRENT_ASSERT(i != m_access_list.end());
|
||||
|
||||
if (i != j) m_access_list.erase(next(i), j);
|
||||
if (i->start == first)
|
||||
|
@ -200,22 +200,22 @@ namespace detail
|
|||
|| (j == m_access_list.end()
|
||||
&& last != max_addr<Addr>()))
|
||||
{
|
||||
assert(j == m_access_list.end() || last < minus_one(j->start));
|
||||
TORRENT_ASSERT(j == m_access_list.end() || last < minus_one(j->start));
|
||||
if (last_access != flags)
|
||||
j = m_access_list.insert(j, range(plus_one(last), last_access));
|
||||
}
|
||||
|
||||
if (j != m_access_list.end() && j->access == flags) m_access_list.erase(j);
|
||||
assert(!m_access_list.empty());
|
||||
TORRENT_ASSERT(!m_access_list.empty());
|
||||
}
|
||||
|
||||
int access(Addr const& addr) const
|
||||
{
|
||||
assert(!m_access_list.empty());
|
||||
TORRENT_ASSERT(!m_access_list.empty());
|
||||
typename range_t::const_iterator i = m_access_list.upper_bound(addr);
|
||||
if (i != m_access_list.begin()) --i;
|
||||
assert(i != m_access_list.end());
|
||||
assert(i->start <= addr && (boost::next(i) == m_access_list.end()
|
||||
TORRENT_ASSERT(i != m_access_list.end());
|
||||
TORRENT_ASSERT(i->start <= addr && (boost::next(i) == m_access_list.end()
|
||||
|| addr < boost::next(i)->start));
|
||||
return i->access;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace aux
|
|||
|
||||
void increment()
|
||||
{
|
||||
assert(m_bucket_iterator != m_bucket_end);
|
||||
TORRENT_ASSERT(m_bucket_iterator != m_bucket_end);
|
||||
++m_iterator;
|
||||
while (m_iterator == m_bucket_iterator->first.end())
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ namespace aux
|
|||
|
||||
node_entry const& dereference() const
|
||||
{
|
||||
assert(m_bucket_iterator != m_bucket_end);
|
||||
TORRENT_ASSERT(m_bucket_iterator != m_bucket_end);
|
||||
return *m_iterator;
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ public:
|
|||
|
||||
int bucket_size(int bucket)
|
||||
{
|
||||
assert(bucket >= 0 && bucket < 160);
|
||||
TORRENT_ASSERT(bucket >= 0 && bucket < 160);
|
||||
return (int)m_buckets[bucket].first.size();
|
||||
}
|
||||
int bucket_size() const { return m_bucket_size; }
|
||||
|
|
|
@ -176,6 +176,9 @@ namespace libtorrent
|
|||
void set_non_prioritized(bool b)
|
||||
{ m_non_prioritized = b; }
|
||||
|
||||
void fast_reconnect(bool r) { m_fast_reconnect = r; }
|
||||
bool fast_reconnect() const { return m_fast_reconnect; }
|
||||
|
||||
// this adds an announcement in the announcement queue
|
||||
// it will let the peer know that we have the given piece
|
||||
void announce_piece(int index);
|
||||
|
@ -380,7 +383,7 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
void set_country(char const* c)
|
||||
{
|
||||
assert(strlen(c) == 2);
|
||||
TORRENT_ASSERT(strlen(c) == 2);
|
||||
m_country[0] = c[0];
|
||||
m_country[1] = c[1];
|
||||
}
|
||||
|
@ -733,6 +736,13 @@ namespace libtorrent
|
|||
// thread that hasn't yet been completely written.
|
||||
int m_outstanding_writing_bytes;
|
||||
|
||||
// if this is true, the disconnection
|
||||
// timestamp is not updated when the connection
|
||||
// is closed. This means the time until we can
|
||||
// reconnect to this peer is shorter, and likely
|
||||
// immediate.
|
||||
bool m_fast_reconnect;
|
||||
|
||||
#ifndef NDEBUG
|
||||
public:
|
||||
bool m_in_constructor;
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace libtorrent
|
|||
|
||||
big_number(std::string const& s)
|
||||
{
|
||||
assert(s.size() >= 20);
|
||||
TORRENT_ASSERT(s.size() >= 20);
|
||||
int sl = int(s.size()) < size ? int(s.size()) : size;
|
||||
std::memcpy(m_number, &s[0], sl);
|
||||
}
|
||||
|
@ -126,10 +126,10 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
unsigned char& operator[](int i)
|
||||
{ assert(i >= 0 && i < number_size); return m_number[i]; }
|
||||
{ TORRENT_ASSERT(i >= 0 && i < number_size); return m_number[i]; }
|
||||
|
||||
unsigned char const& operator[](int i) const
|
||||
{ assert(i >= 0 && i < number_size); return m_number[i]; }
|
||||
{ TORRENT_ASSERT(i >= 0 && i < number_size); return m_number[i]; }
|
||||
|
||||
typedef const unsigned char* const_iterator;
|
||||
typedef unsigned char* iterator;
|
||||
|
|
|
@ -282,7 +282,7 @@ namespace libtorrent
|
|||
// functor that compares indices on downloading_pieces
|
||||
struct has_index
|
||||
{
|
||||
has_index(int i): index(i) { assert(i >= 0); }
|
||||
has_index(int i): index(i) { TORRENT_ASSERT(i >= 0); }
|
||||
bool operator()(const downloading_piece& p) const
|
||||
{ return p.index == index; }
|
||||
int index;
|
||||
|
@ -308,8 +308,8 @@ namespace libtorrent
|
|||
, piece_priority(1)
|
||||
, index(index_)
|
||||
{
|
||||
assert(peer_count_ >= 0);
|
||||
assert(index_ >= 0);
|
||||
TORRENT_ASSERT(peer_count_ >= 0);
|
||||
TORRENT_ASSERT(index_ >= 0);
|
||||
}
|
||||
|
||||
// the number of peers that has this piece
|
||||
|
@ -341,7 +341,7 @@ namespace libtorrent
|
|||
};
|
||||
|
||||
bool have() const { return index == we_have_index; }
|
||||
void set_have() { index = we_have_index; assert(have()); }
|
||||
void set_have() { index = we_have_index; TORRENT_ASSERT(have()); }
|
||||
|
||||
bool filtered() const { return piece_priority == filter_priority; }
|
||||
void filtered(bool f) { piece_priority = f ? filter_priority : 0; }
|
||||
|
@ -447,8 +447,8 @@ namespace libtorrent
|
|||
|
||||
inline int piece_picker::blocks_in_piece(int index) const
|
||||
{
|
||||
assert(index >= 0);
|
||||
assert(index < (int)m_piece_map.size());
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < (int)m_piece_map.size());
|
||||
if (index+1 == (int)m_piece_map.size())
|
||||
return m_blocks_in_last_piece;
|
||||
else
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace libtorrent
|
|||
Distance m = 0;
|
||||
Distance N = std::distance(start, end);
|
||||
|
||||
assert(N >= n);
|
||||
TORRENT_ASSERT(N >= n);
|
||||
|
||||
while (m < n)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,594 @@
|
|||
/*
|
||||
|
||||
Copyright (c) 2006, Arvid Norberg
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TORRENT_SESSION_IMPL_HPP_INCLUDED
|
||||
#define TORRENT_SESSION_IMPL_HPP_INCLUDED
|
||||
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <list>
|
||||
#include <deque>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
#endif
|
||||
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include "libtorrent/torrent_handle.hpp"
|
||||
#include "libtorrent/entry.hpp"
|
||||
#include "libtorrent/torrent_info.hpp"
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/peer_connection.hpp"
|
||||
#include "libtorrent/peer_id.hpp"
|
||||
#include "libtorrent/policy.hpp"
|
||||
#include "libtorrent/tracker_manager.hpp"
|
||||
#include "libtorrent/peer_info.hpp"
|
||||
#include "libtorrent/alert.hpp"
|
||||
#include "libtorrent/fingerprint.hpp"
|
||||
#include "libtorrent/debug.hpp"
|
||||
#include "libtorrent/peer_request.hpp"
|
||||
#include "libtorrent/piece_block_progress.hpp"
|
||||
#include "libtorrent/ip_filter.hpp"
|
||||
#include "libtorrent/config.hpp"
|
||||
#include "libtorrent/session_settings.hpp"
|
||||
#include "libtorrent/kademlia/dht_tracker.hpp"
|
||||
#include "libtorrent/session_status.hpp"
|
||||
#include "libtorrent/session.hpp"
|
||||
#include "libtorrent/stat.hpp"
|
||||
#include "libtorrent/file_pool.hpp"
|
||||
#include "libtorrent/bandwidth_manager.hpp"
|
||||
#include "libtorrent/natpmp.hpp"
|
||||
#include "libtorrent/upnp.hpp"
|
||||
#include "libtorrent/lsd.hpp"
|
||||
#include "libtorrent/socket_type.hpp"
|
||||
#include "libtorrent/connection_queue.hpp"
|
||||
#include "libtorrent/disk_io_thread.hpp"
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
namespace aux
|
||||
{
|
||||
struct session_impl;
|
||||
|
||||
// this data is shared between the main thread and the
|
||||
// thread that initialize pieces
|
||||
struct piece_checker_data
|
||||
{
|
||||
piece_checker_data()
|
||||
: processing(false), progress(0.f), abort(false) {}
|
||||
|
||||
boost::shared_ptr<torrent> torrent_ptr;
|
||||
fs::path save_path;
|
||||
|
||||
sha1_hash info_hash;
|
||||
|
||||
void parse_resume_data(
|
||||
const entry& rd
|
||||
, const torrent_info& info
|
||||
, std::string& error);
|
||||
|
||||
std::vector<int> piece_map;
|
||||
std::vector<piece_picker::downloading_piece> unfinished_pieces;
|
||||
std::vector<piece_picker::block_info> block_info;
|
||||
std::vector<tcp::endpoint> peers;
|
||||
entry resume_data;
|
||||
|
||||
// this is true if this torrent is being processed (checked)
|
||||
// if it is not being processed, then it can be removed from
|
||||
// the queue without problems, otherwise the abort flag has
|
||||
// to be set.
|
||||
bool processing;
|
||||
|
||||
// is filled in by storage::initialize_pieces()
|
||||
// and represents the progress. It should be a
|
||||
// value in the range [0, 1]
|
||||
float progress;
|
||||
|
||||
// abort defaults to false and is typically
|
||||
// filled in by torrent_handle when the user
|
||||
// aborts the torrent
|
||||
bool abort;
|
||||
};
|
||||
|
||||
struct checker_impl: boost::noncopyable
|
||||
{
|
||||
checker_impl(session_impl& s): m_ses(s), m_abort(false) {}
|
||||
void operator()();
|
||||
piece_checker_data* find_torrent(const sha1_hash& info_hash);
|
||||
void remove_torrent(sha1_hash const& info_hash);
|
||||
|
||||
#ifndef NDEBUG
|
||||
void check_invariant() const;
|
||||
#endif
|
||||
|
||||
// when the files has been checked
|
||||
// the torrent is added to the session
|
||||
session_impl& m_ses;
|
||||
|
||||
mutable boost::mutex m_mutex;
|
||||
boost::condition m_cond;
|
||||
|
||||
// a list of all torrents that are currently in queue
|
||||
// or checking their files
|
||||
std::deque<boost::shared_ptr<piece_checker_data> > m_torrents;
|
||||
std::deque<boost::shared_ptr<piece_checker_data> > m_processing;
|
||||
|
||||
bool m_abort;
|
||||
};
|
||||
|
||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
||||
struct tracker_logger;
|
||||
#endif
|
||||
|
||||
// this is the link between the main thread and the
|
||||
// thread started to run the main downloader loop
|
||||
struct session_impl: boost::noncopyable
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
friend class ::libtorrent::peer_connection;
|
||||
#endif
|
||||
friend struct checker_impl;
|
||||
friend class invariant_access;
|
||||
typedef std::map<boost::shared_ptr<socket_type>
|
||||
, boost::intrusive_ptr<peer_connection> >
|
||||
connection_map;
|
||||
typedef std::map<sha1_hash, boost::shared_ptr<torrent> > torrent_map;
|
||||
|
||||
session_impl(
|
||||
std::pair<int, int> listen_port_range
|
||||
, fingerprint const& cl_fprint
|
||||
, char const* listen_interface = "0.0.0.0");
|
||||
~session_impl();
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
void add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent*)> ext);
|
||||
#endif
|
||||
void operator()();
|
||||
|
||||
void open_listen_port();
|
||||
|
||||
void async_accept();
|
||||
void on_incoming_connection(boost::shared_ptr<socket_type> const& s
|
||||
, boost::weak_ptr<socket_acceptor> const& as, asio::error_code const& e);
|
||||
|
||||
// must be locked to access the data
|
||||
// in this struct
|
||||
typedef boost::recursive_mutex mutex_t;
|
||||
mutable mutex_t m_mutex;
|
||||
|
||||
boost::weak_ptr<torrent> find_torrent(const sha1_hash& info_hash);
|
||||
peer_id const& get_peer_id() const { return m_peer_id; }
|
||||
|
||||
void close_connection(boost::intrusive_ptr<peer_connection> const& p);
|
||||
void connection_failed(boost::shared_ptr<socket_type> const& s
|
||||
, tcp::endpoint const& a, char const* message);
|
||||
|
||||
void set_settings(session_settings const& s);
|
||||
session_settings const& settings() const { return m_settings; }
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
void add_dht_node(std::pair<std::string, int> const& node);
|
||||
void add_dht_node(udp::endpoint n);
|
||||
void add_dht_router(std::pair<std::string, int> const& node);
|
||||
void set_dht_settings(dht_settings const& s);
|
||||
dht_settings const& get_dht_settings() const { return m_dht_settings; }
|
||||
void start_dht(entry const& startup_state);
|
||||
void stop_dht();
|
||||
entry dht_state() const;
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
void set_pe_settings(pe_settings const& settings);
|
||||
pe_settings const& get_pe_settings() const { return m_pe_settings; }
|
||||
#endif
|
||||
|
||||
// called when a port mapping is successful, or a router returns
|
||||
// a failure to map a port
|
||||
void on_port_mapping(int tcp_port, int udp_port, std::string const& errmsg);
|
||||
|
||||
bool is_aborted() const { return m_abort; }
|
||||
|
||||
void set_ip_filter(ip_filter const& f);
|
||||
void set_port_filter(port_filter const& f);
|
||||
|
||||
bool listen_on(
|
||||
std::pair<int, int> const& port_range
|
||||
, const char* net_interface = 0);
|
||||
bool is_listening() const;
|
||||
|
||||
torrent_handle add_torrent(
|
||||
torrent_info const& ti
|
||||
, fs::path const& save_path
|
||||
, entry const& resume_data
|
||||
, bool compact_mode
|
||||
, int block_size
|
||||
, storage_constructor_type sc);
|
||||
|
||||
torrent_handle add_torrent(
|
||||
char const* tracker_url
|
||||
, sha1_hash const& info_hash
|
||||
, char const* name
|
||||
, fs::path const& save_path
|
||||
, entry const& resume_data
|
||||
, bool compact_mode
|
||||
, int block_size
|
||||
, storage_constructor_type sc);
|
||||
|
||||
void remove_torrent(torrent_handle const& h);
|
||||
|
||||
std::vector<torrent_handle> get_torrents();
|
||||
|
||||
void set_severity_level(alert::severity_t s);
|
||||
std::auto_ptr<alert> pop_alert();
|
||||
|
||||
int upload_rate_limit() const;
|
||||
int download_rate_limit() const;
|
||||
|
||||
void set_download_rate_limit(int bytes_per_second);
|
||||
void set_upload_rate_limit(int bytes_per_second);
|
||||
void set_max_half_open_connections(int limit);
|
||||
void set_max_connections(int limit);
|
||||
void set_max_uploads(int limit);
|
||||
|
||||
int max_connections() const { return m_max_connections; }
|
||||
int max_uploads() const { return m_max_uploads; }
|
||||
|
||||
int num_uploads() const { return m_num_unchoked; }
|
||||
int num_connections() const
|
||||
{ return m_connections.size(); }
|
||||
|
||||
void unchoke_peer(peer_connection& c)
|
||||
{
|
||||
c.send_unchoke();
|
||||
++m_num_unchoked;
|
||||
}
|
||||
|
||||
session_status status() const;
|
||||
void set_peer_id(peer_id const& id);
|
||||
void set_key(int key);
|
||||
unsigned short listen_port() const;
|
||||
|
||||
void abort();
|
||||
|
||||
torrent_handle find_torrent_handle(sha1_hash const& info_hash);
|
||||
|
||||
void announce_lsd(sha1_hash const& ih);
|
||||
|
||||
void set_peer_proxy(proxy_settings const& s)
|
||||
{ m_peer_proxy = s; }
|
||||
void set_web_seed_proxy(proxy_settings const& s)
|
||||
{ m_web_seed_proxy = s; }
|
||||
void set_tracker_proxy(proxy_settings const& s)
|
||||
{ m_tracker_proxy = s; }
|
||||
|
||||
proxy_settings const& peer_proxy() const
|
||||
{ return m_peer_proxy; }
|
||||
proxy_settings const& web_seed_proxy() const
|
||||
{ return m_web_seed_proxy; }
|
||||
proxy_settings const& tracker_proxy() const
|
||||
{ return m_tracker_proxy; }
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
void set_dht_proxy(proxy_settings const& s)
|
||||
{ m_dht_proxy = s; }
|
||||
proxy_settings const& dht_proxy() const
|
||||
{ return m_dht_proxy; }
|
||||
#endif
|
||||
|
||||
void start_lsd();
|
||||
void start_natpmp();
|
||||
void start_upnp();
|
||||
|
||||
void stop_lsd();
|
||||
void stop_natpmp();
|
||||
void stop_upnp();
|
||||
|
||||
// handles delayed alerts
|
||||
alert_manager m_alerts;
|
||||
|
||||
// private:
|
||||
|
||||
void on_lsd_peer(tcp::endpoint peer, sha1_hash const& ih);
|
||||
|
||||
// this is where all active sockets are stored.
|
||||
// the selector can sleep while there's no activity on
|
||||
// them
|
||||
io_service m_io_service;
|
||||
asio::strand m_strand;
|
||||
|
||||
// the file pool that all storages in this session's
|
||||
// torrents uses. It sets a limit on the number of
|
||||
// open files by this session.
|
||||
// file pool must be destructed after the torrents
|
||||
// since they will still have references to it
|
||||
// when they are destructed.
|
||||
file_pool m_files;
|
||||
|
||||
// handles disk io requests asynchronously
|
||||
disk_io_thread m_disk_thread;
|
||||
|
||||
// this is a list of half-open tcp connections
|
||||
// (only outgoing connections)
|
||||
// this has to be one of the last
|
||||
// members to be destructed
|
||||
connection_queue m_half_open;
|
||||
|
||||
// the bandwidth manager is responsible for
|
||||
// handing out bandwidth to connections that
|
||||
// asks for it, it can also throttle the
|
||||
// rate.
|
||||
bandwidth_manager<peer_connection, torrent> m_download_channel;
|
||||
bandwidth_manager<peer_connection, torrent> m_upload_channel;
|
||||
|
||||
bandwidth_manager<peer_connection, torrent>* m_bandwidth_manager[2];
|
||||
|
||||
tracker_manager m_tracker_manager;
|
||||
torrent_map m_torrents;
|
||||
|
||||
// this maps sockets to their peer_connection
|
||||
// object. It is the complete list of all connected
|
||||
// peers.
|
||||
connection_map m_connections;
|
||||
|
||||
// filters incoming connections
|
||||
ip_filter m_ip_filter;
|
||||
|
||||
// filters outgoing connections
|
||||
port_filter m_port_filter;
|
||||
|
||||
// the peer id that is generated at the start of the session
|
||||
peer_id m_peer_id;
|
||||
|
||||
// the key is an id that is used to identify the
|
||||
// client with the tracker only. It is randomized
|
||||
// at startup
|
||||
int m_key;
|
||||
|
||||
// the range of ports we try to listen on
|
||||
std::pair<int, int> m_listen_port_range;
|
||||
|
||||
// the ip-address of the interface
|
||||
// we are supposed to listen on.
|
||||
// if the ip is set to zero, it means
|
||||
// that we should let the os decide which
|
||||
// interface to listen on
|
||||
tcp::endpoint m_listen_interface;
|
||||
|
||||
// this is typically set to the same as the local
|
||||
// listen port. In case a NAT port forward was
|
||||
// successfully opened, this will be set to the
|
||||
// port that is open on the external (NAT) interface
|
||||
// on the NAT box itself. This is the port that has
|
||||
// to be published to peers, since this is the port
|
||||
// the client is reachable through.
|
||||
int m_external_listen_port;
|
||||
|
||||
boost::shared_ptr<socket_acceptor> m_listen_socket;
|
||||
|
||||
// the settings for the client
|
||||
session_settings m_settings;
|
||||
// the proxy settings for different
|
||||
// kinds of connections
|
||||
proxy_settings m_peer_proxy;
|
||||
proxy_settings m_web_seed_proxy;
|
||||
proxy_settings m_tracker_proxy;
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
proxy_settings m_dht_proxy;
|
||||
#endif
|
||||
|
||||
// set to true when the session object
|
||||
// is being destructed and the thread
|
||||
// should exit
|
||||
volatile bool m_abort;
|
||||
|
||||
int m_max_uploads;
|
||||
int m_max_connections;
|
||||
|
||||
// the number of unchoked peers
|
||||
int m_num_unchoked;
|
||||
|
||||
// this is initialized to the unchoke_interval
|
||||
// session_setting and decreased every second.
|
||||
// when it reaches zero, it is reset to the
|
||||
// unchoke_interval and the unchoke set is
|
||||
// recomputed.
|
||||
int m_unchoke_time_scaler;
|
||||
|
||||
// works like unchoke_time_scaler but it
|
||||
// is only decresed when the unchoke set
|
||||
// is recomputed, and when it reaches zero,
|
||||
// the optimistic unchoke is moved to another peer.
|
||||
int m_optimistic_unchoke_time_scaler;
|
||||
|
||||
// works like unchoke_time_scaler. Each time
|
||||
// it reaches 0, and all the connections are
|
||||
// used, the worst connection will be disconnected
|
||||
// from the torrent with the most peers
|
||||
int m_disconnect_time_scaler;
|
||||
|
||||
// statistics gathered from all torrents.
|
||||
stat m_stat;
|
||||
|
||||
// is false by default and set to true when
|
||||
// the first incoming connection is established
|
||||
// this is used to know if the client is behind
|
||||
// NAT or not.
|
||||
bool m_incoming_connection;
|
||||
|
||||
void second_tick(asio::error_code const& e);
|
||||
ptime m_last_tick;
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
boost::intrusive_ptr<dht::dht_tracker> m_dht;
|
||||
dht_settings m_dht_settings;
|
||||
// if this is set to true, the dht listen port
|
||||
// will be set to the same as the tcp listen port
|
||||
// and will be synchronlized with it as it changes
|
||||
// it defaults to true
|
||||
bool m_dht_same_port;
|
||||
|
||||
// see m_external_listen_port. This is the same
|
||||
// but for the udp port used by the DHT.
|
||||
int m_external_udp_port;
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
pe_settings m_pe_settings;
|
||||
#endif
|
||||
|
||||
boost::shared_ptr<natpmp> m_natpmp;
|
||||
boost::shared_ptr<upnp> m_upnp;
|
||||
boost::shared_ptr<lsd> m_lsd;
|
||||
|
||||
// the timer used to fire the second_tick
|
||||
deadline_timer m_timer;
|
||||
|
||||
// the index of the torrent that will be offered to
|
||||
// connect to a peer next time second_tick is called.
|
||||
// This implements a round robin.
|
||||
int m_next_connect_torrent;
|
||||
#ifndef NDEBUG
|
||||
void check_invariant(const char *place = 0);
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_STATS
|
||||
// logger used to write bandwidth usage statistics
|
||||
std::ofstream m_stats_logger;
|
||||
int m_second_counter;
|
||||
#endif
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
boost::shared_ptr<logger> create_log(std::string const& name
|
||||
, int instance, bool append = true);
|
||||
|
||||
// this list of tracker loggers serves as tracker_callbacks when
|
||||
// shutting down. This list is just here to keep them alive during
|
||||
// whe shutting down process
|
||||
std::list<boost::shared_ptr<tracker_logger> > m_tracker_loggers;
|
||||
|
||||
public:
|
||||
boost::shared_ptr<logger> m_logger;
|
||||
private:
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
typedef std::list<boost::function<boost::shared_ptr<
|
||||
torrent_plugin>(torrent*)> > extension_list_t;
|
||||
|
||||
extension_list_t m_extensions;
|
||||
#endif
|
||||
|
||||
// data shared between the main thread
|
||||
// and the checker thread
|
||||
checker_impl m_checker_impl;
|
||||
|
||||
// the main working thread
|
||||
boost::scoped_ptr<boost::thread> m_thread;
|
||||
|
||||
// the thread that calls initialize_pieces()
|
||||
// on all torrents before they start downloading
|
||||
boost::scoped_ptr<boost::thread> m_checker_thread;
|
||||
};
|
||||
|
||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
||||
struct tracker_logger : request_callback
|
||||
{
|
||||
tracker_logger(session_impl& ses): m_ses(ses) {}
|
||||
void tracker_warning(std::string const& str)
|
||||
{
|
||||
debug_log("*** tracker warning: " + str);
|
||||
}
|
||||
|
||||
void tracker_response(tracker_request const&
|
||||
, std::vector<peer_entry>& peers
|
||||
, int interval
|
||||
, int complete
|
||||
, int incomplete)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << "TRACKER RESPONSE:\n"
|
||||
"interval: " << interval << "\n"
|
||||
"peers:\n";
|
||||
for (std::vector<peer_entry>::const_iterator i = peers.begin();
|
||||
i != peers.end(); ++i)
|
||||
{
|
||||
s << " " << std::setfill(' ') << std::setw(16) << i->ip
|
||||
<< " " << std::setw(5) << std::dec << i->port << " ";
|
||||
if (!i->pid.is_all_zeros()) s << " " << i->pid;
|
||||
s << "\n";
|
||||
}
|
||||
debug_log(s.str());
|
||||
}
|
||||
|
||||
void tracker_request_timed_out(
|
||||
tracker_request const&)
|
||||
{
|
||||
debug_log("*** tracker timed out");
|
||||
}
|
||||
|
||||
void tracker_request_error(
|
||||
tracker_request const&
|
||||
, int response_code
|
||||
, const std::string& str)
|
||||
{
|
||||
debug_log(std::string("*** tracker error: ")
|
||||
+ boost::lexical_cast<std::string>(response_code) + ": "
|
||||
+ str);
|
||||
}
|
||||
|
||||
void debug_log(const std::string& line)
|
||||
{
|
||||
(*m_ses.m_logger) << line << "\n";
|
||||
}
|
||||
session_impl& m_ses;
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -90,8 +90,8 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(bytes_payload >= 0);
|
||||
assert(bytes_protocol >= 0);
|
||||
TORRENT_ASSERT(bytes_payload >= 0);
|
||||
TORRENT_ASSERT(bytes_protocol >= 0);
|
||||
|
||||
m_downloaded_payload += bytes_payload;
|
||||
m_total_download_payload += bytes_payload;
|
||||
|
@ -103,8 +103,8 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(bytes_payload >= 0);
|
||||
assert(bytes_protocol >= 0);
|
||||
TORRENT_ASSERT(bytes_payload >= 0);
|
||||
TORRENT_ASSERT(bytes_protocol >= 0);
|
||||
|
||||
m_uploaded_payload += bytes_payload;
|
||||
m_total_upload_payload += bytes_payload;
|
||||
|
@ -132,8 +132,8 @@ namespace libtorrent
|
|||
// transfers from earlier connections.
|
||||
void add_stat(size_type downloaded, size_type uploaded)
|
||||
{
|
||||
assert(downloaded >= 0);
|
||||
assert(uploaded >= 0);
|
||||
TORRENT_ASSERT(downloaded >= 0);
|
||||
TORRENT_ASSERT(uploaded >= 0);
|
||||
m_total_download_payload += downloaded;
|
||||
m_total_upload_payload += uploaded;
|
||||
}
|
||||
|
@ -143,14 +143,14 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
void check_invariant() const
|
||||
{
|
||||
assert(m_mean_upload_rate >= 0);
|
||||
assert(m_mean_download_rate >= 0);
|
||||
assert(m_mean_upload_payload_rate >= 0);
|
||||
assert(m_mean_download_payload_rate >= 0);
|
||||
assert(m_total_upload_payload >= 0);
|
||||
assert(m_total_download_payload >= 0);
|
||||
assert(m_total_upload_protocol >= 0);
|
||||
assert(m_total_download_protocol >= 0);
|
||||
TORRENT_ASSERT(m_mean_upload_rate >= 0);
|
||||
TORRENT_ASSERT(m_mean_download_rate >= 0);
|
||||
TORRENT_ASSERT(m_mean_upload_payload_rate >= 0);
|
||||
TORRENT_ASSERT(m_mean_download_payload_rate >= 0);
|
||||
TORRENT_ASSERT(m_total_upload_payload >= 0);
|
||||
TORRENT_ASSERT(m_total_download_payload >= 0);
|
||||
TORRENT_ASSERT(m_total_upload_protocol >= 0);
|
||||
TORRENT_ASSERT(m_total_download_protocol >= 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace libtorrent
|
|||
if (timebase_info.denom == 0)
|
||||
mach_timebase_info(&timebase_info);
|
||||
// make sure we don't overflow
|
||||
assert((at >= 0 && at >= at / 1000 * timebase_info.numer / timebase_info.denom)
|
||||
TORRENT_ASSERT((at >= 0 && at >= at / 1000 * timebase_info.numer / timebase_info.denom)
|
||||
|| (at < 0 && at < at / 1000 * timebase_info.numer / timebase_info.denom));
|
||||
return at / 1000 * timebase_info.numer / timebase_info.denom;
|
||||
}
|
||||
|
@ -199,11 +199,11 @@ namespace libtorrent
|
|||
if (timebase_info.denom == 0)
|
||||
{
|
||||
mach_timebase_info(&timebase_info);
|
||||
assert(timebase_info.numer > 0);
|
||||
assert(timebase_info.denom > 0);
|
||||
TORRENT_ASSERT(timebase_info.numer > 0);
|
||||
TORRENT_ASSERT(timebase_info.denom > 0);
|
||||
}
|
||||
// make sure we don't overflow
|
||||
assert((ms >= 0 && ms <= ms * timebase_info.denom / timebase_info.numer * 1000)
|
||||
TORRENT_ASSERT((ms >= 0 && ms <= ms * timebase_info.denom / timebase_info.numer * 1000)
|
||||
|| (ms < 0 && ms > ms * timebase_info.denom / timebase_info.numer * 1000));
|
||||
return ms * timebase_info.denom / timebase_info.numer * 1000;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
// make sure we don't overflow
|
||||
boost::int64_t ret = (pc * 1000 / performace_counter_frequency.QuadPart) * 1000;
|
||||
assert((pc >= 0 && pc >= ret) || (pc < 0 && pc < ret));
|
||||
TORRENT_ASSERT((pc >= 0 && pc >= ret) || (pc < 0 && pc < ret));
|
||||
#endif
|
||||
return (pc * 1000 / performace_counter_frequency.QuadPart) * 1000;
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
// make sure we don't overflow
|
||||
boost::int64_t ret = (ms / 1000) * performace_counter_frequency.QuadPart / 1000;
|
||||
assert((ms >= 0 && ms <= ret)
|
||||
TORRENT_ASSERT((ms >= 0 && ms <= ret)
|
||||
|| (ms < 0 && ms > ret));
|
||||
#endif
|
||||
return (ms / 1000) * performace_counter_frequency.QuadPart / 1000;
|
||||
|
|
|
@ -152,7 +152,7 @@ namespace libtorrent
|
|||
void set_sequenced_download_threshold(int threshold);
|
||||
|
||||
bool verify_resume_data(entry& rd, std::string& error)
|
||||
{ assert(m_storage); return m_storage->verify_resume_data(rd, error); }
|
||||
{ TORRENT_ASSERT(m_storage); return m_storage->verify_resume_data(rd, error); }
|
||||
|
||||
void second_tick(stat& accumulator, float tick_interval);
|
||||
|
||||
|
@ -205,7 +205,7 @@ namespace libtorrent
|
|||
peer_connection* connect_to_peer(policy::peer* peerinfo);
|
||||
|
||||
void set_ratio(float ratio)
|
||||
{ assert(ratio >= 0.0f); m_ratio = ratio; }
|
||||
{ TORRENT_ASSERT(ratio >= 0.0f); m_ratio = ratio; }
|
||||
|
||||
float ratio() const
|
||||
{ return m_ratio; }
|
||||
|
@ -362,7 +362,7 @@ namespace libtorrent
|
|||
// returns true if we have downloaded the given piece
|
||||
bool have_piece(int index) const
|
||||
{
|
||||
assert(index >= 0 && index < (signed)m_have_pieces.size());
|
||||
TORRENT_ASSERT(index >= 0 && index < (signed)m_have_pieces.size());
|
||||
return m_have_pieces[index];
|
||||
}
|
||||
|
||||
|
@ -377,14 +377,14 @@ namespace libtorrent
|
|||
{
|
||||
if (m_picker.get())
|
||||
{
|
||||
assert(!is_seed());
|
||||
assert(index >= 0 && index < (signed)m_have_pieces.size());
|
||||
TORRENT_ASSERT(!is_seed());
|
||||
TORRENT_ASSERT(index >= 0 && index < (signed)m_have_pieces.size());
|
||||
m_picker->inc_refcount(index);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
else
|
||||
{
|
||||
assert(is_seed());
|
||||
TORRENT_ASSERT(is_seed());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -393,13 +393,13 @@ namespace libtorrent
|
|||
{
|
||||
if (m_picker.get())
|
||||
{
|
||||
assert(!is_seed());
|
||||
TORRENT_ASSERT(!is_seed());
|
||||
m_picker->inc_refcount_all();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
else
|
||||
{
|
||||
assert(is_seed());
|
||||
TORRENT_ASSERT(is_seed());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -409,19 +409,19 @@ namespace libtorrent
|
|||
{
|
||||
if (m_picker.get())
|
||||
{
|
||||
assert(!is_seed());
|
||||
assert(index >= 0 && index < (signed)m_have_pieces.size());
|
||||
TORRENT_ASSERT(!is_seed());
|
||||
TORRENT_ASSERT(index >= 0 && index < (signed)m_have_pieces.size());
|
||||
m_picker->dec_refcount(index);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
else
|
||||
{
|
||||
assert(is_seed());
|
||||
TORRENT_ASSERT(is_seed());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int block_size() const { assert(m_block_size > 0); return m_block_size; }
|
||||
int block_size() const { TORRENT_ASSERT(m_block_size > 0); return m_block_size; }
|
||||
|
||||
// this will tell all peers that we just got his piece
|
||||
// and also let the piece picker know that we have this piece
|
||||
|
@ -464,7 +464,7 @@ namespace libtorrent
|
|||
void piece_finished(int index, bool passed_hash_check);
|
||||
void piece_failed(int index);
|
||||
void received_redundant_data(int num_bytes)
|
||||
{ assert(num_bytes > 0); m_total_redundant_bytes += num_bytes; }
|
||||
{ TORRENT_ASSERT(num_bytes > 0); m_total_redundant_bytes += num_bytes; }
|
||||
|
||||
// this is true if we have all the pieces
|
||||
bool is_seed() const
|
||||
|
@ -485,7 +485,7 @@ namespace libtorrent
|
|||
alert_manager& alerts() const;
|
||||
piece_picker& picker()
|
||||
{
|
||||
assert(m_picker.get());
|
||||
TORRENT_ASSERT(m_picker.get());
|
||||
return *m_picker;
|
||||
}
|
||||
bool has_picker() const
|
||||
|
@ -494,7 +494,7 @@ namespace libtorrent
|
|||
}
|
||||
policy& get_policy()
|
||||
{
|
||||
assert(m_policy);
|
||||
TORRENT_ASSERT(m_policy);
|
||||
return *m_policy;
|
||||
}
|
||||
piece_manager& filesystem();
|
||||
|
|
|
@ -398,8 +398,8 @@ namespace libtorrent
|
|||
, m_chk(c)
|
||||
, m_info_hash(h)
|
||||
{
|
||||
assert(m_ses != 0);
|
||||
assert(m_chk != 0);
|
||||
TORRENT_ASSERT(m_ses != 0);
|
||||
TORRENT_ASSERT(m_chk != 0);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace libtorrent
|
|||
|
||||
std::vector<std::string> const& url_seeds() const
|
||||
{
|
||||
assert(!m_half_metadata);
|
||||
TORRENT_ASSERT(!m_half_metadata);
|
||||
return m_url_seeds;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ namespace libtorrent
|
|||
|
||||
int num_files(bool storage = false) const
|
||||
{
|
||||
assert(m_piece_length > 0);
|
||||
TORRENT_ASSERT(m_piece_length > 0);
|
||||
if (!storage || m_remapped_files.empty())
|
||||
return (int)m_files.size();
|
||||
else
|
||||
|
@ -179,23 +179,23 @@ namespace libtorrent
|
|||
{
|
||||
if (!storage || m_remapped_files.empty())
|
||||
{
|
||||
assert(index >= 0 && index < (int)m_files.size());
|
||||
TORRENT_ASSERT(index >= 0 && index < (int)m_files.size());
|
||||
return m_files[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(index >= 0 && index < (int)m_remapped_files.size());
|
||||
TORRENT_ASSERT(index >= 0 && index < (int)m_remapped_files.size());
|
||||
return m_remapped_files[index];
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<announce_entry>& trackers() const { return m_urls; }
|
||||
|
||||
size_type total_size() const { assert(m_piece_length > 0); return m_total_size; }
|
||||
size_type piece_length() const { assert(m_piece_length > 0); return m_piece_length; }
|
||||
int num_pieces() const { assert(m_piece_length > 0); return m_num_pieces; }
|
||||
size_type total_size() const { TORRENT_ASSERT(m_piece_length > 0); return m_total_size; }
|
||||
size_type piece_length() const { TORRENT_ASSERT(m_piece_length > 0); return m_piece_length; }
|
||||
int num_pieces() const { TORRENT_ASSERT(m_piece_length > 0); return m_num_pieces; }
|
||||
const sha1_hash& info_hash() const { return m_info_hash; }
|
||||
const std::string& name() const { assert(m_piece_length > 0); return m_name; }
|
||||
const std::string& name() const { TORRENT_ASSERT(m_piece_length > 0); return m_name; }
|
||||
|
||||
// ------- start deprecation -------
|
||||
// this functionaily will be removed in a future version
|
||||
|
@ -213,9 +213,9 @@ namespace libtorrent
|
|||
|
||||
const sha1_hash& hash_for_piece(int index) const
|
||||
{
|
||||
assert(index >= 0);
|
||||
assert(index < (int)m_piece_hash.size());
|
||||
assert(!m_half_metadata);
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < (int)m_piece_hash.size());
|
||||
TORRENT_ASSERT(!m_half_metadata);
|
||||
return m_piece_hash[index];
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ namespace libtorrent
|
|||
|
||||
nodes_t const& nodes() const
|
||||
{
|
||||
assert(!m_half_metadata);
|
||||
TORRENT_ASSERT(!m_half_metadata);
|
||||
return m_nodes;
|
||||
}
|
||||
|
||||
|
|
|
@ -534,7 +534,7 @@ public:
|
|||
template <class Mutable_Buffers>
|
||||
std::size_t read_some(Mutable_Buffers const& buffers, asio::error_code& ec)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
aux::read_some_visitor_ec<Mutable_Buffers>(buffers, ec)
|
||||
, m_variant
|
||||
|
@ -544,7 +544,7 @@ public:
|
|||
template <class Mutable_Buffers>
|
||||
std::size_t read_some(Mutable_Buffers const& buffers)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
aux::read_some_visitor<Mutable_Buffers>(buffers)
|
||||
, m_variant
|
||||
|
@ -554,7 +554,7 @@ public:
|
|||
template <class Mutable_Buffers, class Handler>
|
||||
void async_read_some(Mutable_Buffers const& buffers, Handler const& handler)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
aux::async_read_some_visitor<Mutable_Buffers, Handler>(buffers, handler)
|
||||
, m_variant
|
||||
|
@ -564,7 +564,7 @@ public:
|
|||
template <class Const_Buffers, class Handler>
|
||||
void async_write_some(Const_Buffers const& buffers, Handler const& handler)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
aux::async_write_some_visitor<Const_Buffers, Handler>(buffers, handler)
|
||||
, m_variant
|
||||
|
@ -574,7 +574,7 @@ public:
|
|||
template <class Handler>
|
||||
void async_connect(endpoint_type const& endpoint, Handler const& handler)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
aux::async_connect_visitor<endpoint_type, Handler>(endpoint, handler), m_variant
|
||||
);
|
||||
|
@ -583,7 +583,7 @@ public:
|
|||
template <class IO_Control_Command>
|
||||
void io_control(IO_Control_Command& ioc)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
aux::io_control_visitor<IO_Control_Command>(ioc), m_variant
|
||||
);
|
||||
|
@ -592,7 +592,7 @@ public:
|
|||
template <class IO_Control_Command>
|
||||
void io_control(IO_Control_Command& ioc, asio::error_code& ec)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
aux::io_control_visitor_ec<IO_Control_Command>(ioc, ec)
|
||||
, m_variant
|
||||
|
@ -601,14 +601,14 @@ public:
|
|||
|
||||
void bind(endpoint_type const& endpoint)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(aux::bind_visitor<endpoint_type>(endpoint), m_variant);
|
||||
}
|
||||
|
||||
template <class Error_Handler>
|
||||
void bind(endpoint_type const& endpoint, Error_Handler const& error_handler)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
aux::bind_visitor<endpoint_type, Error_Handler>(endpoint, error_handler), m_variant
|
||||
);
|
||||
|
@ -616,14 +616,14 @@ public:
|
|||
|
||||
void open(protocol_type const& p)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(aux::open_visitor<protocol_type>(p), m_variant);
|
||||
}
|
||||
|
||||
template <class Error_Handler>
|
||||
void open(protocol_type const& p, Error_Handler const& error_handler)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
aux::open_visitor<protocol_type, Error_Handler>(p, error_handler), m_variant
|
||||
);
|
||||
|
@ -631,14 +631,14 @@ public:
|
|||
|
||||
void close()
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(aux::close_visitor<>(), m_variant);
|
||||
}
|
||||
|
||||
template <class Error_Handler>
|
||||
void close(Error_Handler const& error_handler)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
aux::close_visitor<Error_Handler>(error_handler), m_variant
|
||||
);
|
||||
|
@ -646,14 +646,14 @@ public:
|
|||
|
||||
std::size_t in_avail()
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(aux::in_avail_visitor<>(), m_variant);
|
||||
}
|
||||
|
||||
template <class Error_Handler>
|
||||
std::size_t in_avail(Error_Handler const& error_handler)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
aux::in_avail_visitor<Error_Handler>(error_handler), m_variant
|
||||
);
|
||||
|
@ -661,13 +661,13 @@ public:
|
|||
|
||||
endpoint_type remote_endpoint()
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(aux::remote_endpoint_visitor<endpoint_type>(), m_variant);
|
||||
}
|
||||
|
||||
endpoint_type remote_endpoint(asio::error_code& ec)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
aux::remote_endpoint_visitor_ec<endpoint_type>(ec), m_variant
|
||||
);
|
||||
|
@ -675,13 +675,13 @@ public:
|
|||
|
||||
endpoint_type local_endpoint()
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(aux::local_endpoint_visitor<endpoint_type>(), m_variant);
|
||||
}
|
||||
|
||||
endpoint_type local_endpoint(asio::error_code& ec)
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
aux::local_endpoint_visitor_ec<endpoint_type>(ec), m_variant
|
||||
);
|
||||
|
@ -689,7 +689,7 @@ public:
|
|||
|
||||
asio::io_service& io_service()
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
aux::io_service_visitor<asio::io_service>(), m_variant
|
||||
);
|
||||
|
@ -697,7 +697,7 @@ public:
|
|||
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
assert(instantiated());
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
aux::lowest_layer_visitor<lowest_layer_type>(), m_variant
|
||||
);
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace libtorrent
|
|||
void write_request(peer_request const& r);
|
||||
void write_cancel(peer_request const& r) {}
|
||||
void write_have(int index) {}
|
||||
void write_piece(peer_request const& r, char* buffer) { assert(false); }
|
||||
void write_piece(peer_request const& r, char* buffer) { TORRENT_ASSERT(false); }
|
||||
void write_keepalive() {}
|
||||
void on_connected();
|
||||
void write_reject_request(peer_request const&) {}
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace libtorrent
|
|||
{
|
||||
if (p != end)
|
||||
{
|
||||
assert(*p == '<');
|
||||
TORRENT_ASSERT(*p == '<');
|
||||
*p = 0;
|
||||
}
|
||||
token = xml_string;
|
||||
|
@ -98,7 +98,7 @@ namespace libtorrent
|
|||
break;
|
||||
}
|
||||
|
||||
assert(*p == '>');
|
||||
TORRENT_ASSERT(*p == '>');
|
||||
// save the character that terminated the tag name
|
||||
// it could be both '>' and ' '.
|
||||
char save = *tag_name_end;
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace libtorrent {
|
|||
{
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
assert(!m_alerts.empty());
|
||||
TORRENT_ASSERT(!m_alerts.empty());
|
||||
|
||||
alert* result = m_alerts.front();
|
||||
m_alerts.pop();
|
||||
|
|
|
@ -69,5 +69,9 @@ void assert_fail(char const* expr, int line, char const* file, char const* funct
|
|||
abort();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void assert_fail(char const* expr, int line, char const* file, char const* function) {}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace libtorrent
|
|||
: m_multicast_endpoint(multicast_endpoint)
|
||||
, m_on_receive(handler)
|
||||
{
|
||||
assert(is_multicast(m_multicast_endpoint.address()));
|
||||
TORRENT_ASSERT(is_multicast(m_multicast_endpoint.address()));
|
||||
|
||||
using namespace asio::ip::multicast;
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ namespace libtorrent
|
|||
}
|
||||
else if (out_enc_policy == pe_settings::enabled)
|
||||
{
|
||||
assert(peer_info_struct());
|
||||
TORRENT_ASSERT(peer_info_struct());
|
||||
|
||||
policy::peer* pi = peer_info_struct();
|
||||
if (pi->pe_support == true)
|
||||
|
@ -205,6 +205,7 @@ namespace libtorrent
|
|||
// if this fails, we need to reconnect
|
||||
// fast.
|
||||
pi->connected = time_now() - seconds(m_ses.settings().min_reconnect_time);
|
||||
fast_reconnect(true);
|
||||
|
||||
write_pe1_2_dhkey();
|
||||
m_state = read_pe_dhkey;
|
||||
|
@ -237,7 +238,7 @@ namespace libtorrent
|
|||
void bt_peer_connection::on_metadata()
|
||||
{
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
write_bitfield(t->pieces());
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
if (m_supports_dht_port && m_ses.m_dht)
|
||||
|
@ -249,7 +250,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << time_now_string()
|
||||
|
@ -264,7 +265,7 @@ namespace libtorrent
|
|||
void bt_peer_connection::write_have_all()
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
assert(m_sent_handshake && !m_sent_bitfield);
|
||||
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
|
||||
#ifndef NDEBUG
|
||||
m_sent_bitfield = true;
|
||||
#endif
|
||||
|
@ -279,7 +280,7 @@ namespace libtorrent
|
|||
void bt_peer_connection::write_have_none()
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
assert(m_sent_handshake && !m_sent_bitfield);
|
||||
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
|
||||
#ifndef NDEBUG
|
||||
m_sent_bitfield = true;
|
||||
#endif
|
||||
|
@ -295,8 +296,8 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
assert(associated_torrent().lock()->valid_metadata());
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
|
||||
|
||||
char msg[] = {0,0,0,13, msg_reject_request,0,0,0,0, 0,0,0,0, 0,0,0,0};
|
||||
char* ptr = msg + 5;
|
||||
|
@ -310,8 +311,8 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
assert(associated_torrent().lock()->valid_metadata());
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
|
||||
|
||||
char msg[] = {0,0,0,5, msg_allowed_fast, 0, 0, 0, 0};
|
||||
char* ptr = msg + 5;
|
||||
|
@ -321,7 +322,7 @@ namespace libtorrent
|
|||
|
||||
void bt_peer_connection::get_specific_peer_info(peer_info& p) const
|
||||
{
|
||||
assert(!associated_torrent().expired());
|
||||
TORRENT_ASSERT(!associated_torrent().expired());
|
||||
|
||||
if (is_interesting()) p.flags |= peer_info::interesting;
|
||||
if (is_choked()) p.flags |= peer_info::choked;
|
||||
|
@ -360,10 +361,10 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!m_encrypted);
|
||||
assert(!m_rc4_encrypted);
|
||||
assert(!m_DH_key_exchange.get());
|
||||
assert(!m_sent_handshake);
|
||||
TORRENT_ASSERT(!m_encrypted);
|
||||
TORRENT_ASSERT(!m_rc4_encrypted);
|
||||
TORRENT_ASSERT(!m_DH_key_exchange.get());
|
||||
TORRENT_ASSERT(!m_sent_handshake);
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (is_local())
|
||||
|
@ -396,13 +397,13 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!m_encrypted);
|
||||
assert(!m_rc4_encrypted);
|
||||
assert(is_local());
|
||||
assert(!m_sent_handshake);
|
||||
TORRENT_ASSERT(!m_encrypted);
|
||||
TORRENT_ASSERT(!m_rc4_encrypted);
|
||||
TORRENT_ASSERT(is_local());
|
||||
TORRENT_ASSERT(!m_sent_handshake);
|
||||
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
hasher h;
|
||||
sha1_hash const& info_hash = t->torrent_file().info_hash();
|
||||
|
@ -443,7 +444,7 @@ namespace libtorrent
|
|||
m_DH_key_exchange.reset(); // secret should be invalid at this point
|
||||
|
||||
// write the verification constant and crypto field
|
||||
assert(send_buf.left() == 8 + 4 + 2 + pad_size + 2);
|
||||
TORRENT_ASSERT(send_buf.left() == 8 + 4 + 2 + pad_size + 2);
|
||||
int encrypt_size = send_buf.left();
|
||||
|
||||
int crypto_provide = 0;
|
||||
|
@ -469,7 +470,7 @@ namespace libtorrent
|
|||
write_pe_vc_cryptofield(send_buf, crypto_provide, pad_size);
|
||||
m_RC4_handler->encrypt(send_buf.end - encrypt_size, encrypt_size);
|
||||
|
||||
assert(send_buf.begin == send_buf.end);
|
||||
TORRENT_ASSERT(send_buf.begin == send_buf.end);
|
||||
setup_send();
|
||||
}
|
||||
|
||||
|
@ -477,11 +478,11 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!is_local());
|
||||
assert(!m_encrypted);
|
||||
assert(!m_rc4_encrypted);
|
||||
assert(crypto_select == 0x02 || crypto_select == 0x01);
|
||||
assert(!m_sent_handshake);
|
||||
TORRENT_ASSERT(!is_local());
|
||||
TORRENT_ASSERT(!m_encrypted);
|
||||
TORRENT_ASSERT(!m_rc4_encrypted);
|
||||
TORRENT_ASSERT(crypto_select == 0x02 || crypto_select == 0x01);
|
||||
TORRENT_ASSERT(!m_sent_handshake);
|
||||
|
||||
int pad_size = 0; // rand() % 512; // Keep 0 for now
|
||||
|
||||
|
@ -512,12 +513,12 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(crypto_field <= 0x03 && crypto_field > 0);
|
||||
assert(pad_size == 0); // pad not used yet
|
||||
TORRENT_ASSERT(crypto_field <= 0x03 && crypto_field > 0);
|
||||
TORRENT_ASSERT(pad_size == 0); // pad not used yet
|
||||
// vc,crypto_field,len(pad),pad, (len(ia))
|
||||
assert( (write_buf.left() == 8+4+2+pad_size+2 && is_local()) ||
|
||||
TORRENT_ASSERT( (write_buf.left() == 8+4+2+pad_size+2 && is_local()) ||
|
||||
(write_buf.left() == 8+4+2+pad_size && !is_local()) );
|
||||
assert(!m_sent_handshake);
|
||||
TORRENT_ASSERT(!m_sent_handshake);
|
||||
|
||||
// encrypt(vc, crypto_provide/select, len(Pad), len(IA))
|
||||
// len(pad) is zero for now, len(IA) only for outgoing connections
|
||||
|
@ -544,7 +545,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(secret);
|
||||
TORRENT_ASSERT(secret);
|
||||
|
||||
hasher h;
|
||||
static const char keyA[] = "keyA";
|
||||
|
@ -570,7 +571,7 @@ namespace libtorrent
|
|||
h.update((char const*)stream_key.begin(), 20);
|
||||
const sha1_hash remote_key = h.final();
|
||||
|
||||
assert(!m_RC4_handler.get());
|
||||
TORRENT_ASSERT(!m_RC4_handler.get());
|
||||
m_RC4_handler.reset(new RC4_handler (local_key, remote_key));
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
|
@ -580,9 +581,9 @@ namespace libtorrent
|
|||
|
||||
void bt_peer_connection::send_buffer(char* buf, int size)
|
||||
{
|
||||
assert(buf);
|
||||
assert(size > 0);
|
||||
assert(!m_rc4_encrypted || m_encrypted);
|
||||
TORRENT_ASSERT(buf);
|
||||
TORRENT_ASSERT(size > 0);
|
||||
TORRENT_ASSERT(!m_rc4_encrypted || m_encrypted);
|
||||
|
||||
if (m_rc4_encrypted)
|
||||
m_RC4_handler->encrypt(buf, size);
|
||||
|
@ -592,11 +593,11 @@ namespace libtorrent
|
|||
|
||||
buffer::interval bt_peer_connection::allocate_send_buffer(int size)
|
||||
{
|
||||
assert(!m_rc4_encrypted || m_encrypted);
|
||||
TORRENT_ASSERT(!m_rc4_encrypted || m_encrypted);
|
||||
|
||||
if (m_rc4_encrypted)
|
||||
{
|
||||
assert(m_enc_send_buffer.left() == 0);
|
||||
TORRENT_ASSERT(m_enc_send_buffer.left() == 0);
|
||||
m_enc_send_buffer = peer_connection::allocate_send_buffer(size);
|
||||
return m_enc_send_buffer;
|
||||
}
|
||||
|
@ -609,12 +610,12 @@ namespace libtorrent
|
|||
|
||||
void bt_peer_connection::setup_send()
|
||||
{
|
||||
assert(!m_rc4_encrypted || m_encrypted);
|
||||
TORRENT_ASSERT(!m_rc4_encrypted || m_encrypted);
|
||||
|
||||
if (m_rc4_encrypted && m_enc_send_buffer.left())
|
||||
{
|
||||
assert(m_enc_send_buffer.begin);
|
||||
assert(m_enc_send_buffer.end);
|
||||
TORRENT_ASSERT(m_enc_send_buffer.begin);
|
||||
TORRENT_ASSERT(m_enc_send_buffer.end);
|
||||
|
||||
m_RC4_handler->encrypt(m_enc_send_buffer.begin, m_enc_send_buffer.left());
|
||||
m_enc_send_buffer.end = m_enc_send_buffer.begin;
|
||||
|
@ -625,10 +626,10 @@ namespace libtorrent
|
|||
int bt_peer_connection::get_syncoffset(char const* src, int src_size,
|
||||
char const* target, int target_size) const
|
||||
{
|
||||
assert(target_size >= src_size);
|
||||
assert(src_size > 0);
|
||||
assert(src);
|
||||
assert(target);
|
||||
TORRENT_ASSERT(target_size >= src_size);
|
||||
TORRENT_ASSERT(src_size > 0);
|
||||
TORRENT_ASSERT(src);
|
||||
TORRENT_ASSERT(target);
|
||||
|
||||
int traverse_limit = target_size - src_size;
|
||||
|
||||
|
@ -672,13 +673,13 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!m_sent_handshake);
|
||||
TORRENT_ASSERT(!m_sent_handshake);
|
||||
#ifndef NDEBUG
|
||||
m_sent_handshake = true;
|
||||
#endif
|
||||
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
// add handshake to the send buffer
|
||||
const char version_string[] = "BitTorrent protocol";
|
||||
|
@ -725,7 +726,7 @@ namespace libtorrent
|
|||
, m_ses.get_peer_id().end()
|
||||
, i.begin);
|
||||
i.begin += 20;
|
||||
assert(i.begin == i.end);
|
||||
TORRENT_ASSERT(i.begin == i.end);
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << time_now_string() << " ==> HANDSHAKE\n";
|
||||
|
@ -736,7 +737,7 @@ namespace libtorrent
|
|||
boost::optional<piece_block_progress> bt_peer_connection::downloading_piece_progress() const
|
||||
{
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
buffer::const_interval recv_buffer = receive_buffer();
|
||||
// are we currently receiving a 'piece' message?
|
||||
|
@ -790,7 +791,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
if (packet_size() != 1)
|
||||
throw protocol_error("'choke' message size != 1");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -800,7 +801,7 @@ namespace libtorrent
|
|||
if (!m_supports_fast)
|
||||
{
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
while (!request_queue().empty())
|
||||
{
|
||||
piece_block const& b = request_queue().front();
|
||||
|
@ -821,7 +822,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
if (packet_size() != 1)
|
||||
throw protocol_error("'unchoke' message size != 1");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -838,7 +839,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
if (packet_size() != 1)
|
||||
throw protocol_error("'interested' message size != 1");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -855,7 +856,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
if (packet_size() != 1)
|
||||
throw protocol_error("'not interested' message size != 1");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -872,7 +873,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
if (packet_size() != 5)
|
||||
throw protocol_error("'have' message size != 5");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -894,10 +895,10 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
// if we don't have the metedata, we cannot
|
||||
// verify the bitfield size
|
||||
|
@ -935,7 +936,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
if (packet_size() != 13)
|
||||
throw protocol_error("'request' message size != 13");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -960,7 +961,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
|
||||
buffer::const_interval recv_buffer = receive_buffer();
|
||||
int recv_pos = recv_buffer.end - recv_buffer.begin;
|
||||
|
@ -976,9 +977,9 @@ namespace libtorrent
|
|||
else
|
||||
{
|
||||
// received a bit of both
|
||||
assert(recv_pos - received < 9);
|
||||
assert(recv_pos > 9);
|
||||
assert(9 - (recv_pos - received) <= 9);
|
||||
TORRENT_ASSERT(recv_pos - received < 9);
|
||||
TORRENT_ASSERT(recv_pos > 9);
|
||||
TORRENT_ASSERT(9 - (recv_pos - received) <= 9);
|
||||
m_statistics.received_bytes(
|
||||
recv_pos - 9
|
||||
, 9 - (recv_pos - received));
|
||||
|
@ -1004,7 +1005,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
if (packet_size() != 13)
|
||||
throw protocol_error("'cancel' message size != 13");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -1032,7 +1033,7 @@ namespace libtorrent
|
|||
if (!m_supports_dht_port)
|
||||
throw protocol_error("got 'dht_port' message from peer that doesn't support it");
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
if (packet_size() != 3)
|
||||
throw protocol_error("'dht_port' message size != 3");
|
||||
m_statistics.received_bytes(0, received);
|
||||
|
@ -1128,7 +1129,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
m_statistics.received_bytes(0, received);
|
||||
if (packet_size() < 2)
|
||||
throw protocol_error("'extended' message smaller than 2 bytes");
|
||||
|
@ -1139,7 +1140,7 @@ namespace libtorrent
|
|||
buffer::const_interval recv_buffer = receive_buffer();
|
||||
if (recv_buffer.left() < 2) return;
|
||||
|
||||
assert(*recv_buffer.begin == msg_extended);
|
||||
TORRENT_ASSERT(*recv_buffer.begin == msg_extended);
|
||||
++recv_buffer.begin;
|
||||
|
||||
int extended_id = detail::read_uint8(recv_buffer.begin);
|
||||
|
@ -1169,7 +1170,7 @@ namespace libtorrent
|
|||
if (!packet_finished()) return;
|
||||
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
buffer::const_interval recv_buffer = receive_buffer();
|
||||
|
||||
|
@ -1237,7 +1238,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(received > 0);
|
||||
TORRENT_ASSERT(received > 0);
|
||||
|
||||
// this means the connection has been closed already
|
||||
if (associated_torrent().expired()) return false;
|
||||
|
@ -1265,7 +1266,7 @@ namespace libtorrent
|
|||
+ " size: " + boost::lexical_cast<std::string>(packet_size()));
|
||||
}
|
||||
|
||||
assert(m_message_handler[packet_type] != 0);
|
||||
TORRENT_ASSERT(m_message_handler[packet_type] != 0);
|
||||
|
||||
// call the correct handler for this packet type
|
||||
(this->*m_message_handler[packet_type])(received);
|
||||
|
@ -1277,7 +1278,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
|
||||
char msg[] = {0,0,0,0};
|
||||
send_buffer(msg, sizeof(msg));
|
||||
|
@ -1287,8 +1288,8 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
assert(associated_torrent().lock()->valid_metadata());
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
|
||||
|
||||
char msg[17] = {0,0,0,13, msg_cancel};
|
||||
char* ptr = msg + 5;
|
||||
|
@ -1302,8 +1303,8 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
assert(associated_torrent().lock()->valid_metadata());
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
|
||||
|
||||
char msg[17] = {0,0,0,13, msg_request};
|
||||
char* ptr = msg + 5;
|
||||
|
@ -1319,12 +1320,12 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
assert(m_sent_handshake && !m_sent_bitfield);
|
||||
assert(t->valid_metadata());
|
||||
TORRENT_ASSERT(t);
|
||||
TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield);
|
||||
TORRENT_ASSERT(t->valid_metadata());
|
||||
|
||||
// in this case, have_all or have_none should be sent instead
|
||||
assert(!m_supports_fast || !t->is_seed() || t->num_pieces() != 0);
|
||||
TORRENT_ASSERT(!m_supports_fast || !t->is_seed() || t->num_pieces() != 0);
|
||||
|
||||
if (m_supports_fast && t->is_seed())
|
||||
{
|
||||
|
@ -1344,7 +1345,7 @@ namespace libtorrent
|
|||
int num_lazy_pieces = 0;
|
||||
int lazy_piece = 0;
|
||||
|
||||
assert(t->is_seed() == (std::count(bitfield.begin(), bitfield.end(), true) == num_pieces));
|
||||
TORRENT_ASSERT(t->is_seed() == (std::count(bitfield.begin(), bitfield.end(), true) == num_pieces));
|
||||
if (t->is_seed() && m_ses.settings().lazy_bitfields)
|
||||
{
|
||||
num_lazy_pieces = (std::min)(50, num_pieces / 10);
|
||||
|
@ -1354,7 +1355,7 @@ namespace libtorrent
|
|||
if (rand() % (num_pieces - i) >= num_lazy_pieces - lazy_piece) continue;
|
||||
lazy_pieces[lazy_piece++] = i;
|
||||
}
|
||||
assert(lazy_piece == num_lazy_pieces);
|
||||
TORRENT_ASSERT(lazy_piece == num_lazy_pieces);
|
||||
lazy_piece = 0;
|
||||
}
|
||||
|
||||
|
@ -1397,7 +1398,7 @@ namespace libtorrent
|
|||
if (bitfield[c])
|
||||
i.begin[c >> 3] |= 1 << (7 - (c & 7));
|
||||
}
|
||||
assert(i.end - i.begin == (num_pieces + 7) / 8);
|
||||
TORRENT_ASSERT(i.end - i.begin == (num_pieces + 7) / 8);
|
||||
|
||||
#ifndef NDEBUG
|
||||
m_sent_bitfield = true;
|
||||
|
@ -1428,8 +1429,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << time_now_string() << " ==> EXTENSIONS\n";
|
||||
#endif
|
||||
assert(m_supports_extensions);
|
||||
assert(m_sent_handshake);
|
||||
TORRENT_ASSERT(m_supports_extensions);
|
||||
TORRENT_ASSERT(m_sent_handshake);
|
||||
|
||||
entry handshake(entry::dictionary_t);
|
||||
entry extension_list(entry::dictionary_t);
|
||||
|
@ -1478,7 +1479,7 @@ namespace libtorrent
|
|||
|
||||
std::copy(msg.begin(), msg.end(), i.begin);
|
||||
i.begin += msg.size();
|
||||
assert(i.begin == i.end);
|
||||
TORRENT_ASSERT(i.begin == i.end);
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
std::stringstream ext;
|
||||
|
@ -1494,7 +1495,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
|
||||
if (is_choked()) return;
|
||||
char msg[] = {0,0,0,1,msg_choke};
|
||||
|
@ -1505,7 +1506,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
|
||||
char msg[] = {0,0,0,1,msg_unchoke};
|
||||
send_buffer(msg, sizeof(msg));
|
||||
|
@ -1515,7 +1516,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
|
||||
char msg[] = {0,0,0,1,msg_interested};
|
||||
send_buffer(msg, sizeof(msg));
|
||||
|
@ -1525,7 +1526,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
|
||||
char msg[] = {0,0,0,1,msg_not_interested};
|
||||
send_buffer(msg, sizeof(msg));
|
||||
|
@ -1534,10 +1535,10 @@ namespace libtorrent
|
|||
void bt_peer_connection::write_have(int index)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
assert(associated_torrent().lock()->valid_metadata());
|
||||
assert(index >= 0);
|
||||
assert(index < associated_torrent().lock()->torrent_file().num_pieces());
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < associated_torrent().lock()->torrent_file().num_pieces());
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
|
||||
char msg[] = {0,0,0,5,msg_have,0,0,0,0};
|
||||
char* ptr = msg + 5;
|
||||
|
@ -1549,14 +1550,14 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
char msg[4 + 1 + 4 + 4];
|
||||
char* ptr = msg;
|
||||
assert(r.length <= 16 * 1024);
|
||||
TORRENT_ASSERT(r.length <= 16 * 1024);
|
||||
detail::write_int32(r.length + 1 + 4 + 4, ptr);
|
||||
detail::write_uint8(msg_piece, ptr);
|
||||
detail::write_int32(r.piece, ptr);
|
||||
|
@ -1582,7 +1583,7 @@ namespace libtorrent
|
|||
{
|
||||
match_peer_id(peer_id const& id, peer_connection const* pc)
|
||||
: m_id(id), m_pc(pc)
|
||||
{ assert(pc); }
|
||||
{ TORRENT_ASSERT(pc); }
|
||||
|
||||
bool operator()(std::pair<const address, policy::peer> const& p) const
|
||||
{
|
||||
|
@ -1615,7 +1616,7 @@ namespace libtorrent
|
|||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
|
||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
assert(in_handshake() || !m_rc4_encrypted || m_encrypted);
|
||||
TORRENT_ASSERT(in_handshake() || !m_rc4_encrypted || m_encrypted);
|
||||
if (m_rc4_encrypted && m_encrypted)
|
||||
{
|
||||
buffer::interval wr_buf = wr_recv_buffer();
|
||||
|
@ -1682,17 +1683,17 @@ namespace libtorrent
|
|||
// synchash,skeyhash,vc,crypto_provide,len(pad),pad,encrypt(handshake)
|
||||
reset_recv_buffer(20+20+8+4+2+0+handshake_len);
|
||||
}
|
||||
assert(!packet_finished());
|
||||
TORRENT_ASSERT(!packet_finished());
|
||||
return;
|
||||
}
|
||||
|
||||
// cannot fall through into
|
||||
if (m_state == read_pe_synchash)
|
||||
{
|
||||
assert(!m_encrypted);
|
||||
assert(!m_rc4_encrypted);
|
||||
assert(!is_local());
|
||||
assert(recv_buffer == receive_buffer());
|
||||
TORRENT_ASSERT(!m_encrypted);
|
||||
TORRENT_ASSERT(!m_rc4_encrypted);
|
||||
TORRENT_ASSERT(!is_local());
|
||||
TORRENT_ASSERT(recv_buffer == receive_buffer());
|
||||
|
||||
if (recv_buffer.left() < 20)
|
||||
{
|
||||
|
@ -1706,7 +1707,7 @@ namespace libtorrent
|
|||
|
||||
if (!m_sync_hash.get())
|
||||
{
|
||||
assert(m_sync_bytes_read == 0);
|
||||
TORRENT_ASSERT(m_sync_bytes_read == 0);
|
||||
hasher h;
|
||||
|
||||
// compute synchash (hash('req1',S))
|
||||
|
@ -1729,7 +1730,7 @@ namespace libtorrent
|
|||
|
||||
cut_receive_buffer(bytes_processed, (std::min)(packet_size(), (512+20) - m_sync_bytes_read));
|
||||
|
||||
assert(!packet_finished());
|
||||
TORRENT_ASSERT(!packet_finished());
|
||||
return;
|
||||
}
|
||||
// found complete sync
|
||||
|
@ -1749,10 +1750,10 @@ namespace libtorrent
|
|||
|
||||
if (m_state == read_pe_skey_vc)
|
||||
{
|
||||
assert(!m_encrypted);
|
||||
assert(!m_rc4_encrypted);
|
||||
assert(!is_local());
|
||||
assert(packet_size() == 28);
|
||||
TORRENT_ASSERT(!m_encrypted);
|
||||
TORRENT_ASSERT(!m_rc4_encrypted);
|
||||
TORRENT_ASSERT(!is_local());
|
||||
TORRENT_ASSERT(packet_size() == 28);
|
||||
|
||||
if (!packet_finished()) return;
|
||||
|
||||
|
@ -1793,7 +1794,7 @@ namespace libtorrent
|
|||
{
|
||||
attach_to_torrent(info_hash);
|
||||
t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
}
|
||||
|
||||
init_pe_RC4_handler(m_DH_key_exchange->get_secret(), info_hash);
|
||||
|
@ -1828,10 +1829,10 @@ namespace libtorrent
|
|||
// cannot fall through into
|
||||
if (m_state == read_pe_syncvc)
|
||||
{
|
||||
assert(is_local());
|
||||
assert(!m_encrypted);
|
||||
assert(!m_rc4_encrypted);
|
||||
assert(recv_buffer == receive_buffer());
|
||||
TORRENT_ASSERT(is_local());
|
||||
TORRENT_ASSERT(!m_encrypted);
|
||||
TORRENT_ASSERT(!m_rc4_encrypted);
|
||||
TORRENT_ASSERT(recv_buffer == receive_buffer());
|
||||
|
||||
if (recv_buffer.left() < 8)
|
||||
{
|
||||
|
@ -1846,14 +1847,14 @@ namespace libtorrent
|
|||
// generate the verification constant
|
||||
if (!m_sync_vc.get())
|
||||
{
|
||||
assert(m_sync_bytes_read == 0);
|
||||
TORRENT_ASSERT(m_sync_bytes_read == 0);
|
||||
|
||||
m_sync_vc.reset (new char[8]);
|
||||
std::fill(m_sync_vc.get(), m_sync_vc.get() + 8, 0);
|
||||
m_RC4_handler->decrypt(m_sync_vc.get(), 8);
|
||||
}
|
||||
|
||||
assert(m_sync_vc.get());
|
||||
TORRENT_ASSERT(m_sync_vc.get());
|
||||
int syncoffset = get_syncoffset(m_sync_vc.get(), 8
|
||||
, recv_buffer.begin, recv_buffer.left());
|
||||
|
||||
|
@ -1867,7 +1868,7 @@ namespace libtorrent
|
|||
|
||||
cut_receive_buffer(bytes_processed, (std::min)(packet_size(), (512+8) - m_sync_bytes_read));
|
||||
|
||||
assert(!packet_finished());
|
||||
TORRENT_ASSERT(!packet_finished());
|
||||
return;
|
||||
}
|
||||
// found complete sync
|
||||
|
@ -1889,9 +1890,9 @@ namespace libtorrent
|
|||
|
||||
if (m_state == read_pe_cryptofield) // local/remote
|
||||
{
|
||||
assert(!m_encrypted);
|
||||
assert(!m_rc4_encrypted);
|
||||
assert(packet_size() == 4+2);
|
||||
TORRENT_ASSERT(!m_encrypted);
|
||||
TORRENT_ASSERT(!m_rc4_encrypted);
|
||||
TORRENT_ASSERT(packet_size() == 4+2);
|
||||
|
||||
if (!packet_finished()) return;
|
||||
|
||||
|
@ -2001,7 +2002,7 @@ namespace libtorrent
|
|||
|
||||
if (m_state == read_pe_pad)
|
||||
{
|
||||
assert(!m_encrypted);
|
||||
TORRENT_ASSERT(!m_encrypted);
|
||||
if (!packet_finished()) return;
|
||||
|
||||
int pad_size = is_local() ? packet_size() : packet_size() - 2;
|
||||
|
@ -2043,8 +2044,8 @@ namespace libtorrent
|
|||
|
||||
if (m_state == read_pe_ia)
|
||||
{
|
||||
assert(!is_local());
|
||||
assert(!m_encrypted);
|
||||
TORRENT_ASSERT(!is_local());
|
||||
TORRENT_ASSERT(!m_encrypted);
|
||||
|
||||
if (!packet_finished()) return;
|
||||
|
||||
|
@ -2073,7 +2074,7 @@ namespace libtorrent
|
|||
|
||||
if (m_state == init_bt_handshake)
|
||||
{
|
||||
assert(m_encrypted);
|
||||
TORRENT_ASSERT(m_encrypted);
|
||||
|
||||
// decrypt remaining received bytes
|
||||
if (m_rc4_encrypted)
|
||||
|
@ -2103,7 +2104,7 @@ namespace libtorrent
|
|||
m_ses.get_pe_settings().out_enc_policy == pe_settings::enabled)
|
||||
{
|
||||
policy::peer* pi = peer_info_struct();
|
||||
assert(pi);
|
||||
TORRENT_ASSERT(pi);
|
||||
|
||||
pi->pe_support = true;
|
||||
}
|
||||
|
@ -2137,7 +2138,7 @@ namespace libtorrent
|
|||
#endif
|
||||
m_state = read_pe_dhkey;
|
||||
cut_receive_buffer(0, dh_key_len);
|
||||
assert(!packet_finished());
|
||||
TORRENT_ASSERT(!packet_finished());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2166,7 +2167,7 @@ namespace libtorrent
|
|||
// fall through
|
||||
if (m_state == read_info_hash)
|
||||
{
|
||||
assert(packet_size() == 28);
|
||||
TORRENT_ASSERT(packet_size() == 28);
|
||||
|
||||
if (!packet_finished()) return;
|
||||
recv_buffer = receive_buffer();
|
||||
|
@ -2230,7 +2231,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
// if this is a local connection, we have already
|
||||
// sent the handshake
|
||||
|
@ -2238,7 +2239,7 @@ namespace libtorrent
|
|||
// if (t->valid_metadata())
|
||||
// write_bitfield(t->pieces());
|
||||
|
||||
assert(t->get_policy().has_connection(this));
|
||||
TORRENT_ASSERT(t->get_policy().has_connection(this));
|
||||
|
||||
m_state = read_peer_id;
|
||||
reset_recv_buffer(20);
|
||||
|
@ -2249,10 +2250,10 @@ namespace libtorrent
|
|||
{
|
||||
if (!t)
|
||||
{
|
||||
assert(!packet_finished()); // TODO
|
||||
TORRENT_ASSERT(!packet_finished()); // TODO
|
||||
return;
|
||||
}
|
||||
assert(packet_size() == 20);
|
||||
TORRENT_ASSERT(packet_size() == 20);
|
||||
|
||||
if (!packet_finished()) return;
|
||||
recv_buffer = receive_buffer();
|
||||
|
@ -2285,7 +2286,7 @@ namespace libtorrent
|
|||
, match_peer_id(pid, this));
|
||||
if (i != p.end_peer())
|
||||
{
|
||||
assert(i->second.connection->pid() == pid);
|
||||
TORRENT_ASSERT(i->second.connection->pid() == pid);
|
||||
// we found another connection with the same peer-id
|
||||
// which connection should be closed in order to be
|
||||
// sure that the other end closes the same connection?
|
||||
|
@ -2352,7 +2353,7 @@ namespace libtorrent
|
|||
m_ses.get_pe_settings().out_enc_policy == pe_settings::enabled)
|
||||
{
|
||||
policy::peer* pi = peer_info_struct();
|
||||
assert(pi);
|
||||
TORRENT_ASSERT(pi);
|
||||
|
||||
pi->pe_support = false;
|
||||
}
|
||||
|
@ -2369,7 +2370,7 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
assert(!packet_finished());
|
||||
TORRENT_ASSERT(!packet_finished());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2407,24 +2408,24 @@ namespace libtorrent
|
|||
m_state = read_packet;
|
||||
reset_recv_buffer(packet_size);
|
||||
}
|
||||
assert(!packet_finished());
|
||||
TORRENT_ASSERT(!packet_finished());
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_state == read_packet)
|
||||
{
|
||||
assert(recv_buffer == receive_buffer());
|
||||
TORRENT_ASSERT(recv_buffer == receive_buffer());
|
||||
if (!t) return;
|
||||
if (dispatch_message(bytes_transferred))
|
||||
{
|
||||
m_state = read_packet_size;
|
||||
reset_recv_buffer(4);
|
||||
}
|
||||
assert(!packet_finished());
|
||||
TORRENT_ASSERT(!packet_finished());
|
||||
return;
|
||||
}
|
||||
|
||||
assert(!packet_finished());
|
||||
TORRENT_ASSERT(!packet_finished());
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
|
@ -2469,7 +2470,7 @@ namespace libtorrent
|
|||
std::remove_if(m_payloads.begin(), m_payloads.end(), range_below_zero)
|
||||
, m_payloads.end());
|
||||
|
||||
assert(amount_payload <= (int)bytes_transferred);
|
||||
TORRENT_ASSERT(amount_payload <= (int)bytes_transferred);
|
||||
m_statistics.sent_bytes(amount_payload, bytes_transferred - amount_payload);
|
||||
}
|
||||
|
||||
|
@ -2477,10 +2478,10 @@ namespace libtorrent
|
|||
void bt_peer_connection::check_invariant() const
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
assert( (bool(m_state != read_pe_dhkey) || m_DH_key_exchange.get())
|
||||
TORRENT_ASSERT( (bool(m_state != read_pe_dhkey) || m_DH_key_exchange.get())
|
||||
|| !is_local());
|
||||
|
||||
assert(!m_rc4_encrypted || m_RC4_handler.get());
|
||||
TORRENT_ASSERT(!m_rc4_encrypted || m_RC4_handler.get());
|
||||
#endif
|
||||
if (!m_in_constructor)
|
||||
peer_connection::check_invariant();
|
||||
|
@ -2490,7 +2491,7 @@ namespace libtorrent
|
|||
for (std::deque<range>::const_iterator i = m_payloads.begin();
|
||||
i != m_payloads.end() - 1; ++i)
|
||||
{
|
||||
assert(i->start + i->length <= (i+1)->start);
|
||||
TORRENT_ASSERT(i->start + i->length <= (i+1)->start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace libtorrent
|
|||
{
|
||||
if (i->connecting) ++num_connecting;
|
||||
}
|
||||
assert(num_connecting == m_num_connecting);
|
||||
TORRENT_ASSERT(num_connecting == m_num_connecting);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -118,7 +118,7 @@ namespace libtorrent
|
|||
, m_queue.end(), boost::bind(&entry::connecting, _1) == false);
|
||||
while (i != m_queue.end())
|
||||
{
|
||||
assert(i->connecting == false);
|
||||
TORRENT_ASSERT(i->connecting == false);
|
||||
ptime expire = time_now() + i->timeout;
|
||||
if (m_num_connecting == 0)
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
struct function_guard
|
||||
{
|
||||
function_guard(bool& v): val(v) { assert(!val); val = true; }
|
||||
function_guard(bool& v): val(v) { TORRENT_ASSERT(!val); val = true; }
|
||||
~function_guard() { val = false; }
|
||||
|
||||
bool& val;
|
||||
|
@ -159,7 +159,7 @@ namespace libtorrent
|
|||
function_guard guard_(m_in_timeout_function);
|
||||
#endif
|
||||
|
||||
assert(!e || e == asio::error::operation_aborted);
|
||||
TORRENT_ASSERT(!e || e == asio::error::operation_aborted);
|
||||
if (e) return;
|
||||
|
||||
ptime next_expire = max_time();
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace libtorrent
|
|||
void disk_io_thread::add_job(disk_io_job const& j
|
||||
, boost::function<void(int, disk_io_job const&)> const& f)
|
||||
{
|
||||
assert(!j.callback);
|
||||
TORRENT_ASSERT(!j.callback);
|
||||
boost::mutex::scoped_lock l(m_mutex);
|
||||
|
||||
std::deque<disk_io_job>::reverse_iterator i = m_jobs.rbegin();
|
||||
|
@ -174,7 +174,7 @@ namespace libtorrent
|
|||
k->callback.swap(const_cast<boost::function<void(int, disk_io_job const&)>&>(f));
|
||||
if (j.action == disk_io_job::write)
|
||||
m_queue_buffer_size += j.buffer_size;
|
||||
assert(j.storage.get());
|
||||
TORRENT_ASSERT(j.storage.get());
|
||||
m_signal.notify_all();
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ namespace libtorrent
|
|||
++m_allocations;
|
||||
#endif
|
||||
l.unlock();
|
||||
assert(j.buffer_size <= m_block_size);
|
||||
TORRENT_ASSERT(j.buffer_size <= m_block_size);
|
||||
if (j.buffer == 0)
|
||||
{
|
||||
ret = -1;
|
||||
|
@ -257,8 +257,8 @@ namespace libtorrent
|
|||
#ifdef TORRENT_DISK_STATS
|
||||
m_log << log_time() << " write " << j.buffer_size << std::endl;
|
||||
#endif
|
||||
assert(j.buffer);
|
||||
assert(j.buffer_size <= m_block_size);
|
||||
TORRENT_ASSERT(j.buffer);
|
||||
TORRENT_ASSERT(j.buffer_size <= m_block_size);
|
||||
j.storage->write_impl(j.buffer, j.piece, j.offset
|
||||
, j.buffer_size);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace
|
|||
template <class T>
|
||||
void call_destructor(T* o)
|
||||
{
|
||||
assert(o);
|
||||
TORRENT_ASSERT(o);
|
||||
o->~T();
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ namespace libtorrent
|
|||
case dictionary_t:
|
||||
return dict() == e.dict();
|
||||
default:
|
||||
assert(m_type == undefined_t);
|
||||
TORRENT_ASSERT(m_type == undefined_t);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ namespace libtorrent
|
|||
new (data) dictionary_type;
|
||||
break;
|
||||
default:
|
||||
assert(m_type == undefined_t);
|
||||
TORRENT_ASSERT(m_type == undefined_t);
|
||||
m_type = undefined_t;
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ namespace libtorrent
|
|||
call_destructor(reinterpret_cast<dictionary_type*>(data));
|
||||
break;
|
||||
default:
|
||||
assert(m_type == undefined_t);
|
||||
TORRENT_ASSERT(m_type == undefined_t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -281,12 +281,12 @@ namespace libtorrent
|
|||
void entry::swap(entry& e)
|
||||
{
|
||||
// not implemented
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
||||
void entry::print(std::ostream& os, int indent) const
|
||||
{
|
||||
assert(indent >= 0);
|
||||
TORRENT_ASSERT(indent >= 0);
|
||||
for (int i = 0; i < indent; ++i) os << " ";
|
||||
switch (m_type)
|
||||
{
|
||||
|
|
|
@ -87,8 +87,8 @@ namespace libtorrent
|
|||
|
||||
std::string escape_string(const char* str, int len)
|
||||
{
|
||||
assert(str != 0);
|
||||
assert(len >= 0);
|
||||
TORRENT_ASSERT(str != 0);
|
||||
TORRENT_ASSERT(len >= 0);
|
||||
// http://www.ietf.org/rfc/rfc2396.txt
|
||||
// section 2.3
|
||||
// some trackers seems to require that ' is escaped
|
||||
|
@ -121,8 +121,8 @@ namespace libtorrent
|
|||
|
||||
std::string escape_path(const char* str, int len)
|
||||
{
|
||||
assert(str != 0);
|
||||
assert(len >= 0);
|
||||
TORRENT_ASSERT(str != 0);
|
||||
TORRENT_ASSERT(len >= 0);
|
||||
static const char unreserved_chars[] = "/-_.!~*()"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789";
|
||||
|
|
|
@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include "libtorrent/pch.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
// windows part
|
||||
|
@ -91,7 +92,7 @@ namespace
|
|||
if (m == (mode_in | mode_out)) return O_RDWR | O_CREAT | O_BINARY | O_RANDOM;
|
||||
if (m == mode_out) return O_WRONLY | O_CREAT | O_BINARY | O_RANDOM;
|
||||
if (m == mode_in) return O_RDONLY | O_BINARY | O_RANDOM;
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -157,7 +158,7 @@ namespace libtorrent
|
|||
|
||||
void open(fs::path const& path, int mode)
|
||||
{
|
||||
assert(path.is_complete());
|
||||
TORRENT_ASSERT(path.is_complete());
|
||||
close();
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
std::wstring wpath(safe_convert(path.native_file_string()));
|
||||
|
@ -204,8 +205,8 @@ namespace libtorrent
|
|||
|
||||
size_type read(char* buf, size_type num_bytes)
|
||||
{
|
||||
assert(m_open_mode & mode_in);
|
||||
assert(m_fd != -1);
|
||||
TORRENT_ASSERT(m_open_mode & mode_in);
|
||||
TORRENT_ASSERT(m_fd != -1);
|
||||
|
||||
#ifdef _WIN32
|
||||
size_type ret = ::_read(m_fd, buf, num_bytes);
|
||||
|
@ -223,8 +224,8 @@ namespace libtorrent
|
|||
|
||||
size_type write(const char* buf, size_type num_bytes)
|
||||
{
|
||||
assert(m_open_mode & mode_out);
|
||||
assert(m_fd != -1);
|
||||
TORRENT_ASSERT(m_open_mode & mode_out);
|
||||
TORRENT_ASSERT(m_fd != -1);
|
||||
|
||||
// TODO: Test this a bit more, what happens with random failures in
|
||||
// the files?
|
||||
|
@ -261,8 +262,8 @@ namespace libtorrent
|
|||
|
||||
size_type seek(size_type offset, int m = 1)
|
||||
{
|
||||
assert(m_open_mode);
|
||||
assert(m_fd != -1);
|
||||
TORRENT_ASSERT(m_open_mode);
|
||||
TORRENT_ASSERT(m_fd != -1);
|
||||
|
||||
int seekdir = (m == 1)?SEEK_SET:SEEK_END;
|
||||
#ifdef _WIN32
|
||||
|
@ -288,8 +289,8 @@ namespace libtorrent
|
|||
|
||||
size_type tell()
|
||||
{
|
||||
assert(m_open_mode);
|
||||
assert(m_fd != -1);
|
||||
TORRENT_ASSERT(m_open_mode);
|
||||
TORRENT_ASSERT(m_fd != -1);
|
||||
|
||||
#ifdef _WIN32
|
||||
return _telli64(m_fd);
|
||||
|
|
|
@ -43,9 +43,9 @@ namespace libtorrent
|
|||
|
||||
boost::shared_ptr<file> file_pool::open_file(void* st, fs::path const& p, file::open_mode m)
|
||||
{
|
||||
assert(st != 0);
|
||||
assert(p.is_complete());
|
||||
assert(m == file::in || m == (file::in | file::out));
|
||||
TORRENT_ASSERT(st != 0);
|
||||
TORRENT_ASSERT(p.is_complete());
|
||||
TORRENT_ASSERT(m == file::in || m == (file::in | file::out));
|
||||
boost::mutex::scoped_lock l(m_mutex);
|
||||
typedef nth_index<file_set, 0>::type path_view;
|
||||
path_view& pt = get<0>(m_files);
|
||||
|
@ -69,7 +69,7 @@ namespace libtorrent
|
|||
// close the file before we open it with
|
||||
// the new read/write privilages
|
||||
i->file_ptr.reset();
|
||||
assert(e.file_ptr.unique());
|
||||
TORRENT_ASSERT(e.file_ptr.unique());
|
||||
e.file_ptr.reset();
|
||||
e.file_ptr.reset(new file(p, m));
|
||||
e.mode = m;
|
||||
|
@ -86,7 +86,7 @@ namespace libtorrent
|
|||
lru_view& lt = get<1>(m_files);
|
||||
lru_view::iterator i = lt.begin();
|
||||
// the first entry in this view is the least recently used
|
||||
assert(lt.size() == 1 || (i->last_use <= boost::next(i)->last_use));
|
||||
TORRENT_ASSERT(lt.size() == 1 || (i->last_use <= boost::next(i)->last_use));
|
||||
lt.erase(i);
|
||||
}
|
||||
lru_file_entry e(boost::shared_ptr<file>(new file(p, m)));
|
||||
|
@ -100,7 +100,7 @@ namespace libtorrent
|
|||
void file_pool::release(void* st)
|
||||
{
|
||||
boost::mutex::scoped_lock l(m_mutex);
|
||||
assert(st != 0);
|
||||
TORRENT_ASSERT(st != 0);
|
||||
using boost::tie;
|
||||
|
||||
typedef nth_index<file_set, 2>::type key_view;
|
||||
|
@ -113,7 +113,7 @@ namespace libtorrent
|
|||
|
||||
void file_pool::resize(int size)
|
||||
{
|
||||
assert(size > 0);
|
||||
TORRENT_ASSERT(size > 0);
|
||||
if (size == m_size) return;
|
||||
boost::mutex::scoped_lock l(m_mutex);
|
||||
m_size = size;
|
||||
|
@ -126,7 +126,7 @@ namespace libtorrent
|
|||
while (int(m_files.size()) > m_size)
|
||||
{
|
||||
// the first entry in this view is the least recently used
|
||||
assert(lt.size() == 1 || (i->last_use <= boost::next(i)->last_use));
|
||||
TORRENT_ASSERT(lt.size() == 1 || (i->last_use <= boost::next(i)->last_use));
|
||||
lt.erase(i++);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/file.hpp"
|
||||
#include "libtorrent/utf8.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
|
||||
#ifdef UNICODE
|
||||
#include "libtorrent/storage.hpp"
|
||||
|
@ -136,8 +137,8 @@ namespace libtorrent
|
|||
|
||||
void open(const char *file_name, open_flags flags)
|
||||
{
|
||||
assert(file_name);
|
||||
assert(flags & (read_flag | write_flag));
|
||||
TORRENT_ASSERT(file_name);
|
||||
TORRENT_ASSERT(flags & (read_flag | write_flag));
|
||||
|
||||
DWORD access_mask = 0;
|
||||
if (flags & read_flag)
|
||||
|
@ -145,7 +146,7 @@ namespace libtorrent
|
|||
if (flags & write_flag)
|
||||
access_mask |= GENERIC_WRITE;
|
||||
|
||||
assert(access_mask & (GENERIC_READ | GENERIC_WRITE));
|
||||
TORRENT_ASSERT(access_mask & (GENERIC_READ | GENERIC_WRITE));
|
||||
|
||||
#ifdef UNICODE
|
||||
std::wstring wfile_name(safe_convert(file_name));
|
||||
|
@ -198,8 +199,8 @@ namespace libtorrent
|
|||
|
||||
size_type write(const char* buffer, size_type num_bytes)
|
||||
{
|
||||
assert(buffer);
|
||||
assert((DWORD)num_bytes == num_bytes);
|
||||
TORRENT_ASSERT(buffer);
|
||||
TORRENT_ASSERT((DWORD)num_bytes == num_bytes);
|
||||
DWORD bytes_written = 0;
|
||||
if (num_bytes != 0)
|
||||
{
|
||||
|
@ -218,9 +219,9 @@ namespace libtorrent
|
|||
|
||||
size_type read(char* buffer, size_type num_bytes)
|
||||
{
|
||||
assert(buffer);
|
||||
assert(num_bytes >= 0);
|
||||
assert((DWORD)num_bytes == num_bytes);
|
||||
TORRENT_ASSERT(buffer);
|
||||
TORRENT_ASSERT(num_bytes >= 0);
|
||||
TORRENT_ASSERT((DWORD)num_bytes == num_bytes);
|
||||
|
||||
DWORD bytes_read = 0;
|
||||
if (num_bytes != 0)
|
||||
|
@ -250,8 +251,8 @@ namespace libtorrent
|
|||
|
||||
size_type seek(size_type pos, seek_mode from_where)
|
||||
{
|
||||
assert(pos >= 0 || from_where != seek_begin);
|
||||
assert(pos <= 0 || from_where != seek_end);
|
||||
TORRENT_ASSERT(pos >= 0 || from_where != seek_begin);
|
||||
TORRENT_ASSERT(pos <= 0 || from_where != seek_end);
|
||||
LARGE_INTEGER offs;
|
||||
offs.QuadPart = pos;
|
||||
if (FALSE == SetFilePointerEx(
|
||||
|
@ -281,7 +282,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
size_type pos = offs.QuadPart;
|
||||
assert(pos >= 0);
|
||||
TORRENT_ASSERT(pos >= 0);
|
||||
return pos;
|
||||
}
|
||||
/*
|
||||
|
@ -294,7 +295,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
size_type size = s.QuadPart;
|
||||
assert(size >= 0);
|
||||
TORRENT_ASSERT(size >= 0);
|
||||
return size;
|
||||
}
|
||||
*/
|
||||
|
@ -330,7 +331,7 @@ namespace libtorrent
|
|||
|
||||
void file::open(boost::filesystem::path const& p, open_mode m)
|
||||
{
|
||||
assert(p.is_complete());
|
||||
TORRENT_ASSERT(p.is_complete());
|
||||
m_impl->open(p.native_file_string().c_str(), impl::open_flags(m.m_mask));
|
||||
}
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ void http_connection::on_resolve(asio::error_code const& e
|
|||
m_handler(e, m_parser, 0, 0);
|
||||
return;
|
||||
}
|
||||
assert(i != tcp::resolver::iterator());
|
||||
TORRENT_ASSERT(i != tcp::resolver::iterator());
|
||||
m_cc.enqueue(bind(&http_connection::connect, shared_from_this(), _1, *i)
|
||||
, bind(&http_connection::on_connect_timeout, shared_from_this())
|
||||
, m_timeout);
|
||||
|
@ -225,7 +225,7 @@ void http_connection::on_read(asio::error_code const& e
|
|||
if (m_rate_limit)
|
||||
{
|
||||
m_download_quota -= bytes_transferred;
|
||||
assert(m_download_quota >= 0);
|
||||
TORRENT_ASSERT(m_download_quota >= 0);
|
||||
}
|
||||
|
||||
if (e == asio::error::eof)
|
||||
|
@ -254,7 +254,7 @@ void http_connection::on_read(asio::error_code const& e
|
|||
}
|
||||
|
||||
m_read_pos += bytes_transferred;
|
||||
assert(m_read_pos <= int(m_recvbuffer.size()));
|
||||
TORRENT_ASSERT(m_read_pos <= int(m_recvbuffer.size()));
|
||||
|
||||
// having a nonempty path means we should handle redirects
|
||||
if (m_redirect && m_parser.header_finished())
|
||||
|
@ -306,7 +306,7 @@ void http_connection::on_read(asio::error_code const& e
|
|||
}
|
||||
else
|
||||
{
|
||||
assert(!m_bottled);
|
||||
TORRENT_ASSERT(!m_bottled);
|
||||
m_handler(e, m_parser, &m_recvbuffer[0], m_read_pos);
|
||||
m_read_pos = 0;
|
||||
m_last_receive = time_now();
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace libtorrent
|
|||
|
||||
boost::tuple<int, int> http_parser::incoming(buffer::const_interval recv_buffer)
|
||||
{
|
||||
assert(recv_buffer.left() >= m_recv_buffer.left());
|
||||
TORRENT_ASSERT(recv_buffer.left() >= m_recv_buffer.left());
|
||||
boost::tuple<int, int> ret(0, 0);
|
||||
|
||||
// early exit if there's nothing new in the receive buffer
|
||||
|
@ -129,7 +129,7 @@ namespace libtorrent
|
|||
char const* pos = recv_buffer.begin + m_recv_pos;
|
||||
if (m_state == read_status)
|
||||
{
|
||||
assert(!m_finished);
|
||||
TORRENT_ASSERT(!m_finished);
|
||||
char const* newline = std::find(pos, recv_buffer.end, '\n');
|
||||
// if we don't have a full line yet, wait.
|
||||
if (newline == recv_buffer.end) return ret;
|
||||
|
@ -166,7 +166,7 @@ namespace libtorrent
|
|||
|
||||
if (m_state == read_header)
|
||||
{
|
||||
assert(!m_finished);
|
||||
TORRENT_ASSERT(!m_finished);
|
||||
char const* newline = std::find(pos, recv_buffer.end, '\n');
|
||||
std::string line;
|
||||
|
||||
|
@ -226,7 +226,7 @@ namespace libtorrent
|
|||
m_content_length = range_end - range_start + 1;
|
||||
}
|
||||
|
||||
assert(m_recv_pos <= (int)recv_buffer.left());
|
||||
TORRENT_ASSERT(m_recv_pos <= (int)recv_buffer.left());
|
||||
newline = std::find(pos, recv_buffer.end, '\n');
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ namespace libtorrent
|
|||
&& m_content_length >= 0)
|
||||
incoming = m_content_length - m_recv_pos + m_body_start_pos;
|
||||
|
||||
assert(incoming >= 0);
|
||||
TORRENT_ASSERT(incoming >= 0);
|
||||
m_recv_pos += incoming;
|
||||
boost::get<0>(ret) += incoming;
|
||||
|
||||
|
@ -253,7 +253,7 @@ namespace libtorrent
|
|||
|
||||
buffer::const_interval http_parser::get_body() const
|
||||
{
|
||||
assert(m_state == read_body);
|
||||
TORRENT_ASSERT(m_state == read_body);
|
||||
if (m_content_length >= 0)
|
||||
return buffer::const_interval(m_recv_buffer.begin + m_body_start_pos
|
||||
, m_recv_buffer.begin + (std::min)(m_recv_pos
|
||||
|
@ -534,7 +534,7 @@ namespace libtorrent
|
|||
!= bind_interface().is_v4(); ++target);
|
||||
if (target == end)
|
||||
{
|
||||
assert(target_address.address().is_v4() != bind_interface().is_v4());
|
||||
TORRENT_ASSERT(target_address.address().is_v4() != bind_interface().is_v4());
|
||||
if (cb)
|
||||
{
|
||||
std::string tracker_address_type = target_address.address().is_v4() ? "IPv4" : "IPv6";
|
||||
|
@ -619,7 +619,7 @@ namespace libtorrent
|
|||
if (cb) cb->debug_log("tracker send data completed");
|
||||
#endif
|
||||
restart_read_timeout();
|
||||
assert(m_buffer.size() - m_recv_pos > 0);
|
||||
TORRENT_ASSERT(m_buffer.size() - m_recv_pos > 0);
|
||||
m_socket->async_read_some(asio::buffer(&m_buffer[m_recv_pos]
|
||||
, m_buffer.size() - m_recv_pos), bind(&http_tracker_connection::receive
|
||||
, self(), _1, _2));
|
||||
|
@ -650,7 +650,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
restart_read_timeout();
|
||||
assert(bytes_transferred > 0);
|
||||
TORRENT_ASSERT(bytes_transferred > 0);
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
boost::shared_ptr<request_callback> cb = requester();
|
||||
if (cb) cb->debug_log("tracker connection reading "
|
||||
|
@ -669,7 +669,7 @@ namespace libtorrent
|
|||
fail(200, "too large tracker response");
|
||||
return;
|
||||
}
|
||||
assert(http_buffer_size > 0);
|
||||
TORRENT_ASSERT(http_buffer_size > 0);
|
||||
if ((int)m_buffer.size() + http_buffer_size
|
||||
> m_settings.tracker_maximum_response_length)
|
||||
m_buffer.resize(m_settings.tracker_maximum_response_length);
|
||||
|
@ -700,7 +700,7 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
assert(m_buffer.size() - m_recv_pos > 0);
|
||||
TORRENT_ASSERT(m_buffer.size() - m_recv_pos > 0);
|
||||
m_socket->async_read_some(asio::buffer(&m_buffer[m_recv_pos]
|
||||
, m_buffer.size() - m_recv_pos), bind(&http_tracker_connection::receive
|
||||
, self(), _1, _2));
|
||||
|
@ -816,7 +816,7 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
catch (...)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ namespace
|
|||
#ifndef NDEBUG
|
||||
for (int i = 1; i < size; ++i)
|
||||
{
|
||||
assert(compare_id(name_map[i-1]
|
||||
TORRENT_ASSERT(compare_id(name_map[i-1]
|
||||
, name_map[i]));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -43,23 +43,23 @@ namespace libtorrent
|
|||
{
|
||||
if (first.is_v4())
|
||||
{
|
||||
assert(last.is_v4());
|
||||
TORRENT_ASSERT(last.is_v4());
|
||||
m_filter4.add_rule(first.to_v4(), last.to_v4(), flags);
|
||||
}
|
||||
else if (first.is_v6())
|
||||
{
|
||||
assert(last.is_v6());
|
||||
TORRENT_ASSERT(last.is_v6());
|
||||
m_filter6.add_rule(first.to_v6(), last.to_v6(), flags);
|
||||
}
|
||||
else
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
||||
int ip_filter::access(address const& addr) const
|
||||
{
|
||||
if (addr.is_v4())
|
||||
return m_filter4.access(addr.to_v4());
|
||||
assert(addr.is_v6());
|
||||
TORRENT_ASSERT(addr.is_v6());
|
||||
return m_filter6.access(addr.to_v6());
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ void closest_nodes_observer::reply(msg const& in)
|
|||
{
|
||||
if (!m_algorithm)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,15 +126,15 @@ namespace libtorrent { namespace dht
|
|||
|
||||
void intrusive_ptr_add_ref(dht_tracker const* c)
|
||||
{
|
||||
assert(c != 0);
|
||||
assert(c->m_refs >= 0);
|
||||
TORRENT_ASSERT(c != 0);
|
||||
TORRENT_ASSERT(c->m_refs >= 0);
|
||||
++c->m_refs;
|
||||
}
|
||||
|
||||
void intrusive_ptr_release(dht_tracker const* c)
|
||||
{
|
||||
assert(c != 0);
|
||||
assert(c->m_refs > 0);
|
||||
TORRENT_ASSERT(c != 0);
|
||||
TORRENT_ASSERT(c->m_refs > 0);
|
||||
if (--c->m_refs == 0)
|
||||
delete c;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ namespace libtorrent { namespace dht
|
|||
#ifndef NDEBUG
|
||||
std::cerr << "exception-type: " << typeid(exc).name() << std::endl;
|
||||
std::cerr << "what: " << exc.what() << std::endl;
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -263,7 +263,7 @@ namespace libtorrent { namespace dht
|
|||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
|
||||
void dht_tracker::rebind(asio::ip::address listen_interface, int listen_port)
|
||||
|
@ -375,7 +375,7 @@ namespace libtorrent { namespace dht
|
|||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
|
||||
void dht_tracker::announce(sha1_hash const& ih, int listen_port
|
||||
|
@ -411,7 +411,7 @@ namespace libtorrent { namespace dht
|
|||
using libtorrent::entry;
|
||||
using libtorrent::bdecode;
|
||||
|
||||
assert(bytes_transferred > 0);
|
||||
TORRENT_ASSERT(bytes_transferred > 0);
|
||||
|
||||
entry e = bdecode(m_in_buf[current_buffer].begin()
|
||||
, m_in_buf[current_buffer].end());
|
||||
|
@ -654,7 +654,7 @@ namespace libtorrent { namespace dht
|
|||
}
|
||||
TORRENT_LOG(dht_tracker) << e;
|
||||
#endif
|
||||
assert(m.message_id != messages::error);
|
||||
TORRENT_ASSERT(m.message_id != messages::error);
|
||||
m_dht.incoming(m);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
@ -670,7 +670,7 @@ namespace libtorrent { namespace dht
|
|||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
|
||||
entry dht_tracker::state() const
|
||||
|
@ -725,7 +725,7 @@ namespace libtorrent { namespace dht
|
|||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
|
||||
void dht_tracker::add_router_node(std::pair<std::string, int> const& node)
|
||||
|
@ -744,7 +744,7 @@ namespace libtorrent { namespace dht
|
|||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
|
||||
void dht_tracker::on_bootstrap()
|
||||
|
@ -800,7 +800,7 @@ namespace libtorrent { namespace dht
|
|||
using libtorrent::bencode;
|
||||
using libtorrent::entry;
|
||||
entry e(entry::dictionary_t);
|
||||
assert(!m.transaction_id.empty() || m.message_id == messages::error);
|
||||
TORRENT_ASSERT(!m.transaction_id.empty() || m.message_id == messages::error);
|
||||
e["t"] = m.transaction_id;
|
||||
static char const version_str[] = {'L', 'T'
|
||||
, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR};
|
||||
|
@ -814,10 +814,10 @@ namespace libtorrent { namespace dht
|
|||
|
||||
if (m.message_id == messages::error)
|
||||
{
|
||||
assert(m.reply);
|
||||
TORRENT_ASSERT(m.reply);
|
||||
e["y"] = "e";
|
||||
entry error_list(entry::list_t);
|
||||
assert(m.error_code > 200 && m.error_code <= 204);
|
||||
TORRENT_ASSERT(m.error_code > 200 && m.error_code <= 204);
|
||||
error_list.list().push_back(entry(m.error_code));
|
||||
error_list.list().push_back(entry(m.error_msg));
|
||||
e["e"] = error_list;
|
||||
|
@ -891,7 +891,7 @@ namespace libtorrent { namespace dht
|
|||
|
||||
if (m.write_token.type() != entry::undefined_t)
|
||||
a["token"] = m.write_token;
|
||||
assert(m.message_id <= messages::error);
|
||||
TORRENT_ASSERT(m.message_id <= messages::error);
|
||||
e["q"] = messages::ids[m.message_id];
|
||||
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
|
@ -973,7 +973,7 @@ namespace libtorrent { namespace dht
|
|||
// m_send may fail with "no route to host"
|
||||
// but it shouldn't throw since an error code
|
||||
// is passed in instead
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
@ -49,7 +49,7 @@ void find_data_observer::reply(msg const& m)
|
|||
{
|
||||
if (!m_algorithm)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ void node_impl::new_write_key()
|
|||
|
||||
void node_impl::refresh_bucket(int bucket) try
|
||||
{
|
||||
assert(bucket >= 0 && bucket < 160);
|
||||
TORRENT_ASSERT(bucket >= 0 && bucket < 160);
|
||||
|
||||
// generate a random node_id within the given bucket
|
||||
node_id target = generate_id();
|
||||
|
@ -243,7 +243,7 @@ void node_impl::refresh_bucket(int bucket) try
|
|||
target[(num_bits - 1) / 8] |=
|
||||
(~(m_id[(num_bits - 1) / 8])) & (0x80 >> ((num_bits - 1) % 8));
|
||||
|
||||
assert(distance_exp(m_id, target) == bucket);
|
||||
TORRENT_ASSERT(distance_exp(m_id, target) == bucket);
|
||||
|
||||
std::vector<node_entry> start;
|
||||
start.reserve(m_table.bucket_size());
|
||||
|
@ -323,7 +323,7 @@ time_duration node_impl::refresh_timeout()
|
|||
}
|
||||
if (next < now)
|
||||
{
|
||||
assert(refresh > -1);
|
||||
TORRENT_ASSERT(refresh > -1);
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(node) << "refreshing bucket: " << refresh;
|
||||
#endif
|
||||
|
@ -484,7 +484,7 @@ void node_impl::incoming_request(msg const& m)
|
|||
on_announce(m, reply);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
|
||||
if (m_table.need_node(m.id))
|
||||
|
|
|
@ -80,7 +80,7 @@ int distance_exp(node_id const& n1, node_id const& n2)
|
|||
for (node_id::const_iterator i = n1.begin(), j = n2.begin()
|
||||
, end(n1.end()); i != end; ++i, ++j, --byte)
|
||||
{
|
||||
assert(byte >= 0);
|
||||
TORRENT_ASSERT(byte >= 0);
|
||||
boost::uint8_t t = *i ^ *j;
|
||||
if (t == 0) continue;
|
||||
// we have found the first non-zero byte
|
||||
|
|
|
@ -164,8 +164,8 @@ void routing_table::touch_bucket(int bucket)
|
|||
|
||||
ptime routing_table::next_refresh(int bucket)
|
||||
{
|
||||
assert(bucket < 160);
|
||||
assert(bucket >= 0);
|
||||
TORRENT_ASSERT(bucket < 160);
|
||||
TORRENT_ASSERT(bucket >= 0);
|
||||
// lower than or equal to since a refresh of bucket 0 will
|
||||
// effectively refresh the lowest active bucket as well
|
||||
if (bucket < m_lowest_active_bucket && bucket > 0)
|
||||
|
@ -186,8 +186,8 @@ void routing_table::replacement_cache(bucket_t& nodes) const
|
|||
bool routing_table::need_node(node_id const& id)
|
||||
{
|
||||
int bucket_index = distance_exp(m_id, id);
|
||||
assert(bucket_index < (int)m_buckets.size());
|
||||
assert(bucket_index >= 0);
|
||||
TORRENT_ASSERT(bucket_index < (int)m_buckets.size());
|
||||
TORRENT_ASSERT(bucket_index >= 0);
|
||||
bucket_t& b = m_buckets[bucket_index].first;
|
||||
bucket_t& rb = m_buckets[bucket_index].second;
|
||||
|
||||
|
@ -209,8 +209,8 @@ bool routing_table::need_node(node_id const& id)
|
|||
void routing_table::node_failed(node_id const& id)
|
||||
{
|
||||
int bucket_index = distance_exp(m_id, id);
|
||||
assert(bucket_index < (int)m_buckets.size());
|
||||
assert(bucket_index >= 0);
|
||||
TORRENT_ASSERT(bucket_index < (int)m_buckets.size());
|
||||
TORRENT_ASSERT(bucket_index >= 0);
|
||||
bucket_t& b = m_buckets[bucket_index].first;
|
||||
bucket_t& rb = m_buckets[bucket_index].second;
|
||||
|
||||
|
@ -228,7 +228,7 @@ void routing_table::node_failed(node_id const& id)
|
|||
if (i->fail_count >= m_settings.max_fail_count)
|
||||
{
|
||||
b.erase(i);
|
||||
assert(m_lowest_active_bucket <= bucket_index);
|
||||
TORRENT_ASSERT(m_lowest_active_bucket <= bucket_index);
|
||||
while (m_buckets[m_lowest_active_bucket].first.empty()
|
||||
&& m_lowest_active_bucket < 160)
|
||||
{
|
||||
|
@ -259,8 +259,8 @@ bool routing_table::node_seen(node_id const& id, udp::endpoint addr)
|
|||
{
|
||||
if (m_router_nodes.find(addr) != m_router_nodes.end()) return false;
|
||||
int bucket_index = distance_exp(m_id, id);
|
||||
assert(bucket_index < (int)m_buckets.size());
|
||||
assert(bucket_index >= 0);
|
||||
TORRENT_ASSERT(bucket_index < (int)m_buckets.size());
|
||||
TORRENT_ASSERT(bucket_index >= 0);
|
||||
bucket_t& b = m_buckets[bucket_index].first;
|
||||
|
||||
bucket_t::iterator i = std::find_if(b.begin(), b.end()
|
||||
|
@ -274,7 +274,7 @@ bool routing_table::node_seen(node_id const& id, udp::endpoint addr)
|
|||
{
|
||||
// TODO: what do we do if we see a node with
|
||||
// the same id as a node at a different address?
|
||||
// assert(i->addr == addr);
|
||||
// TORRENT_ASSERT(i->addr == addr);
|
||||
|
||||
// we already have the node in our bucket
|
||||
// just move it to the back since it was
|
||||
|
@ -371,11 +371,11 @@ void routing_table::find_node(node_id const& target
|
|||
// vector.
|
||||
std::remove_copy_if(b.begin(), b.end(), std::back_inserter(l)
|
||||
, bind(&node_entry::fail_count, _1));
|
||||
assert((int)l.size() <= count);
|
||||
TORRENT_ASSERT((int)l.size() <= count);
|
||||
|
||||
if ((int)l.size() == count)
|
||||
{
|
||||
assert(std::count_if(l.begin(), l.end()
|
||||
TORRENT_ASSERT(std::count_if(l.begin(), l.end()
|
||||
, boost::bind(&node_entry::fail_count, _1) != 0) == 0);
|
||||
return;
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ void routing_table::find_node(node_id const& target
|
|||
std::copy(tmpb.begin(), tmpb.begin() + to_copy
|
||||
, std::back_inserter(l));
|
||||
|
||||
assert((int)l.size() <= m_bucket_size);
|
||||
TORRENT_ASSERT((int)l.size() <= m_bucket_size);
|
||||
|
||||
// return if we have enough nodes or if the bucket index
|
||||
// is the biggest index available (there are no more buckets)
|
||||
|
@ -407,7 +407,7 @@ void routing_table::find_node(node_id const& target
|
|||
if ((int)l.size() == count
|
||||
|| bucket_index == (int)m_buckets.size() - 1)
|
||||
{
|
||||
assert(std::count_if(l.begin(), l.end()
|
||||
TORRENT_ASSERT(std::count_if(l.begin(), l.end()
|
||||
, boost::bind(&node_entry::fail_count, _1) != 0) == 0);
|
||||
return;
|
||||
}
|
||||
|
@ -421,16 +421,16 @@ void routing_table::find_node(node_id const& target
|
|||
if ((int)l.size() >= count)
|
||||
{
|
||||
l.erase(l.begin() + count, l.end());
|
||||
assert(std::count_if(l.begin(), l.end()
|
||||
TORRENT_ASSERT(std::count_if(l.begin(), l.end()
|
||||
, boost::bind(&node_entry::fail_count, _1) != 0) == 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
assert((int)l.size() == count
|
||||
TORRENT_ASSERT((int)l.size() == count
|
||||
|| std::distance(l.begin(), l.end()) < m_bucket_size);
|
||||
assert((int)l.size() <= count);
|
||||
TORRENT_ASSERT((int)l.size() <= count);
|
||||
|
||||
assert(std::count_if(l.begin(), l.end()
|
||||
TORRENT_ASSERT(std::count_if(l.begin(), l.end()
|
||||
, boost::bind(&node_entry::fail_count, _1) != 0) == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -70,15 +70,15 @@ TORRENT_DEFINE_LOG(rpc)
|
|||
|
||||
void intrusive_ptr_add_ref(observer const* o)
|
||||
{
|
||||
assert(o->m_refs >= 0);
|
||||
assert(o != 0);
|
||||
TORRENT_ASSERT(o->m_refs >= 0);
|
||||
TORRENT_ASSERT(o != 0);
|
||||
++o->m_refs;
|
||||
}
|
||||
|
||||
void intrusive_ptr_release(observer const* o)
|
||||
{
|
||||
assert(o->m_refs > 0);
|
||||
assert(o != 0);
|
||||
TORRENT_ASSERT(o->m_refs > 0);
|
||||
TORRENT_ASSERT(o != 0);
|
||||
if (--o->m_refs == 0)
|
||||
{
|
||||
boost::pool<>& p = o->pool_allocator;
|
||||
|
@ -138,16 +138,16 @@ rpc_manager::~rpc_manager()
|
|||
#ifndef NDEBUG
|
||||
void rpc_manager::check_invariant() const
|
||||
{
|
||||
assert(m_oldest_transaction_id >= 0);
|
||||
assert(m_oldest_transaction_id < max_transactions);
|
||||
assert(m_next_transaction_id >= 0);
|
||||
assert(m_next_transaction_id < max_transactions);
|
||||
assert(!m_transactions[m_next_transaction_id]);
|
||||
TORRENT_ASSERT(m_oldest_transaction_id >= 0);
|
||||
TORRENT_ASSERT(m_oldest_transaction_id < max_transactions);
|
||||
TORRENT_ASSERT(m_next_transaction_id >= 0);
|
||||
TORRENT_ASSERT(m_next_transaction_id < max_transactions);
|
||||
TORRENT_ASSERT(!m_transactions[m_next_transaction_id]);
|
||||
|
||||
for (int i = (m_next_transaction_id + 1) % max_transactions;
|
||||
i != m_oldest_transaction_id; i = (i + 1) % max_transactions)
|
||||
{
|
||||
assert(!m_transactions[i]);
|
||||
TORRENT_ASSERT(!m_transactions[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -246,7 +246,7 @@ bool rpc_manager::incoming(msg const& m)
|
|||
}
|
||||
else
|
||||
{
|
||||
assert(m.message_id != messages::error);
|
||||
TORRENT_ASSERT(m.message_id != messages::error);
|
||||
// this is an incoming request
|
||||
m_incoming(m);
|
||||
}
|
||||
|
@ -268,8 +268,8 @@ time_duration rpc_manager::tick()
|
|||
for (;m_next_transaction_id != m_oldest_transaction_id;
|
||||
m_oldest_transaction_id = (m_oldest_transaction_id + 1) % max_transactions)
|
||||
{
|
||||
assert(m_oldest_transaction_id >= 0);
|
||||
assert(m_oldest_transaction_id < max_transactions);
|
||||
TORRENT_ASSERT(m_oldest_transaction_id >= 0);
|
||||
TORRENT_ASSERT(m_oldest_transaction_id < max_transactions);
|
||||
|
||||
observer_ptr o = m_transactions[m_oldest_transaction_id];
|
||||
if (!o) continue;
|
||||
|
@ -311,9 +311,9 @@ unsigned int rpc_manager::new_transaction_id(observer_ptr o)
|
|||
// since that would break the invariant
|
||||
m_aborted_transactions.push_back(m_transactions[m_next_transaction_id]);
|
||||
m_transactions[m_next_transaction_id] = 0;
|
||||
assert(m_oldest_transaction_id == m_next_transaction_id);
|
||||
TORRENT_ASSERT(m_oldest_transaction_id == m_next_transaction_id);
|
||||
}
|
||||
assert(!m_transactions[tid]);
|
||||
TORRENT_ASSERT(!m_transactions[tid]);
|
||||
m_transactions[tid] = o;
|
||||
if (m_oldest_transaction_id == m_next_transaction_id)
|
||||
{
|
||||
|
@ -332,7 +332,7 @@ void rpc_manager::update_oldest_transaction_id()
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_oldest_transaction_id != m_next_transaction_id);
|
||||
TORRENT_ASSERT(m_oldest_transaction_id != m_next_transaction_id);
|
||||
while (!m_transactions[m_oldest_transaction_id])
|
||||
{
|
||||
m_oldest_transaction_id = (m_oldest_transaction_id + 1)
|
||||
|
@ -358,7 +358,7 @@ void rpc_manager::invoke(int message_id, udp::endpoint target_addr
|
|||
m.reply = false;
|
||||
m.id = m_our_id;
|
||||
m.addr = target_addr;
|
||||
assert(!m_transactions[m_next_transaction_id]);
|
||||
TORRENT_ASSERT(!m_transactions[m_next_transaction_id]);
|
||||
#ifndef NDEBUG
|
||||
int potential_new_id = m_next_transaction_id;
|
||||
#endif
|
||||
|
@ -383,7 +383,7 @@ void rpc_manager::invoke(int message_id, udp::endpoint target_addr
|
|||
catch (std::exception& e)
|
||||
{
|
||||
// m_send may fail with "no route to host"
|
||||
assert(potential_new_id == m_next_transaction_id);
|
||||
TORRENT_ASSERT(potential_new_id == m_next_transaction_id);
|
||||
o->abort();
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ void rpc_manager::reply(msg& m)
|
|||
|
||||
if (m_destructing) return;
|
||||
|
||||
assert(m.reply);
|
||||
TORRENT_ASSERT(m.reply);
|
||||
m.piggy_backed_ping = false;
|
||||
m.id = m_our_id;
|
||||
|
||||
|
@ -406,7 +406,7 @@ void rpc_manager::reply_with_ping(msg& m)
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_destructing) return;
|
||||
assert(m.reply);
|
||||
TORRENT_ASSERT(m.reply);
|
||||
|
||||
m.piggy_backed_ping = true;
|
||||
m.id = m_our_id;
|
||||
|
@ -416,7 +416,7 @@ void rpc_manager::reply_with_ping(msg& m)
|
|||
io::write_uint16(m_next_transaction_id, out);
|
||||
|
||||
observer_ptr o(new (allocator().malloc()) null_observer(allocator()));
|
||||
assert(!m_transactions[m_next_transaction_id]);
|
||||
TORRENT_ASSERT(!m_transactions[m_next_transaction_id]);
|
||||
o->sent = time_now();
|
||||
o->target_addr = m.addr;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsig
|
|||
|
||||
if (i == m_results.end() || i->id != id)
|
||||
{
|
||||
assert(std::find_if(m_results.begin(), m_results.end()
|
||||
TORRENT_ASSERT(std::find_if(m_results.begin(), m_results.end()
|
||||
, bind(&result::id, _1) == id) == m_results.end());
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(traversal) << "adding result: " << id << " " << addr;
|
||||
|
@ -110,11 +110,11 @@ void traversal_algorithm::failed(node_id const& id, bool prevent_request)
|
|||
)
|
||||
);
|
||||
|
||||
assert(i != m_results.end());
|
||||
TORRENT_ASSERT(i != m_results.end());
|
||||
|
||||
if (i != m_results.end())
|
||||
{
|
||||
assert(i->flags & result::queried);
|
||||
TORRENT_ASSERT(i->flags & result::queried);
|
||||
m_failed.insert(i->addr);
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_LOG(traversal) << "failed: " << i->id << " " << i->addr;
|
||||
|
|
|
@ -65,10 +65,10 @@ namespace libtorrent { namespace
|
|||
|
||||
std::pair<int, int> req_to_offset(std::pair<int, int> req, int total_size)
|
||||
{
|
||||
assert(req.first >= 0);
|
||||
assert(req.second > 0);
|
||||
assert(req.second <= 256);
|
||||
assert(req.first + req.second <= 256);
|
||||
TORRENT_ASSERT(req.first >= 0);
|
||||
TORRENT_ASSERT(req.second > 0);
|
||||
TORRENT_ASSERT(req.second <= 256);
|
||||
TORRENT_ASSERT(req.first + req.second <= 256);
|
||||
|
||||
int start = div_round_up(req.first * total_size, 256);
|
||||
int size = div_round_up((req.first + req.second) * total_size, 256) - start;
|
||||
|
@ -82,15 +82,15 @@ namespace libtorrent { namespace
|
|||
|
||||
std::pair<int, int> ret(start, size);
|
||||
|
||||
assert(start >= 0);
|
||||
assert(size > 0);
|
||||
assert(start <= 256);
|
||||
assert(start + size <= 256);
|
||||
TORRENT_ASSERT(start >= 0);
|
||||
TORRENT_ASSERT(size > 0);
|
||||
TORRENT_ASSERT(start <= 256);
|
||||
TORRENT_ASSERT(start + size <= 256);
|
||||
|
||||
// assert the identity of this function
|
||||
#ifndef NDEBUG
|
||||
std::pair<int, int> identity = req_to_offset(ret, total_size);
|
||||
assert(offset == identity);
|
||||
TORRENT_ASSERT(offset == identity);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
@ -124,10 +124,10 @@ namespace libtorrent { namespace
|
|||
bencode(std::back_inserter(m_metadata)
|
||||
, m_torrent.torrent_file().create_info_metadata());
|
||||
|
||||
assert(hasher(&m_metadata[0], m_metadata.size()).final()
|
||||
TORRENT_ASSERT(hasher(&m_metadata[0], m_metadata.size()).final()
|
||||
== m_torrent.torrent_file().info_hash());
|
||||
}
|
||||
assert(!m_metadata.empty());
|
||||
TORRENT_ASSERT(!m_metadata.empty());
|
||||
return m_metadata;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ namespace libtorrent { namespace
|
|||
std::pair<int, int> req = offset_to_req(std::make_pair(offset, size)
|
||||
, total_size);
|
||||
|
||||
assert(req.first + req.second <= (int)m_have_metadata.size());
|
||||
TORRENT_ASSERT(req.first + req.second <= (int)m_have_metadata.size());
|
||||
|
||||
std::fill(
|
||||
m_have_metadata.begin() + req.first
|
||||
|
@ -203,7 +203,7 @@ namespace libtorrent { namespace
|
|||
{
|
||||
for (int i = req.first; i < req.first + req.second; ++i)
|
||||
{
|
||||
assert(m_requested_metadata[i] > 0);
|
||||
TORRENT_ASSERT(m_requested_metadata[i] > 0);
|
||||
if (m_requested_metadata[i] > 0)
|
||||
--m_requested_metadata[i];
|
||||
}
|
||||
|
@ -288,11 +288,11 @@ namespace libtorrent { namespace
|
|||
|
||||
void write_metadata_request(std::pair<int, int> req)
|
||||
{
|
||||
assert(req.first >= 0);
|
||||
assert(req.second > 0);
|
||||
assert(req.first + req.second <= 256);
|
||||
assert(!m_pc.associated_torrent().expired());
|
||||
assert(!m_pc.associated_torrent().lock()->valid_metadata());
|
||||
TORRENT_ASSERT(req.first >= 0);
|
||||
TORRENT_ASSERT(req.second > 0);
|
||||
TORRENT_ASSERT(req.first + req.second <= 256);
|
||||
TORRENT_ASSERT(!m_pc.associated_torrent().expired());
|
||||
TORRENT_ASSERT(!m_pc.associated_torrent().lock()->valid_metadata());
|
||||
|
||||
int start = req.first;
|
||||
int size = req.second;
|
||||
|
@ -309,17 +309,17 @@ namespace libtorrent { namespace
|
|||
detail::write_uint8(0, i.begin);
|
||||
detail::write_uint8(start, i.begin);
|
||||
detail::write_uint8(size - 1, i.begin);
|
||||
assert(i.begin == i.end);
|
||||
TORRENT_ASSERT(i.begin == i.end);
|
||||
m_pc.setup_send();
|
||||
}
|
||||
|
||||
void write_metadata(std::pair<int, int> req)
|
||||
{
|
||||
assert(req.first >= 0);
|
||||
assert(req.second > 0);
|
||||
assert(req.second <= 256);
|
||||
assert(req.first + req.second <= 256);
|
||||
assert(!m_pc.associated_torrent().expired());
|
||||
TORRENT_ASSERT(req.first >= 0);
|
||||
TORRENT_ASSERT(req.second > 0);
|
||||
TORRENT_ASSERT(req.second <= 256);
|
||||
TORRENT_ASSERT(req.first + req.second <= 256);
|
||||
TORRENT_ASSERT(!m_pc.associated_torrent().expired());
|
||||
|
||||
// abort if the peer doesn't support the metadata extension
|
||||
if (m_message_index == 0) return;
|
||||
|
@ -344,7 +344,7 @@ namespace libtorrent { namespace
|
|||
std::copy(metadata.begin() + offset.first
|
||||
, metadata.begin() + offset.first + offset.second, i.begin);
|
||||
i.begin += offset.second;
|
||||
assert(i.begin == i.end);
|
||||
TORRENT_ASSERT(i.begin == i.end);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -356,7 +356,7 @@ namespace libtorrent { namespace
|
|||
detail::write_uint8(m_message_index, i.begin);
|
||||
// means 'have no data'
|
||||
detail::write_uint8(2, i.begin);
|
||||
assert(i.begin == i.end);
|
||||
TORRENT_ASSERT(i.begin == i.end);
|
||||
}
|
||||
m_pc.setup_send();
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ namespace libtorrent { namespace
|
|||
// the number of blocks to request
|
||||
int num_blocks = 256 / (peers + 1);
|
||||
if (num_blocks < 1) num_blocks = 1;
|
||||
assert(num_blocks <= 128);
|
||||
TORRENT_ASSERT(num_blocks <= 128);
|
||||
|
||||
int min_element = (std::numeric_limits<int>::max)();
|
||||
int best_index = 0;
|
||||
|
@ -543,10 +543,10 @@ namespace libtorrent { namespace
|
|||
for (int i = ret.first; i < ret.first + ret.second; ++i)
|
||||
m_requested_metadata[i]++;
|
||||
|
||||
assert(ret.first >= 0);
|
||||
assert(ret.second > 0);
|
||||
assert(ret.second <= 256);
|
||||
assert(ret.first + ret.second <= 256);
|
||||
TORRENT_ASSERT(ret.first >= 0);
|
||||
TORRENT_ASSERT(ret.second > 0);
|
||||
TORRENT_ASSERT(ret.second <= 256);
|
||||
TORRENT_ASSERT(ret.first + ret.second <= 256);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ void natpmp::send_map_request(int i) try
|
|||
{
|
||||
using namespace libtorrent::detail;
|
||||
|
||||
assert(m_currently_mapping == -1
|
||||
TORRENT_ASSERT(m_currently_mapping == -1
|
||||
|| m_currently_mapping == i);
|
||||
m_currently_mapping = i;
|
||||
mapping& m = m_mappings[i];
|
||||
|
@ -232,7 +232,7 @@ void natpmp::on_reply(asio::error_code const& e
|
|||
|
||||
m_send_timer.cancel();
|
||||
|
||||
assert(m_currently_mapping >= 0);
|
||||
TORRENT_ASSERT(m_currently_mapping >= 0);
|
||||
int i = m_currently_mapping;
|
||||
mapping& m = m_mappings[i];
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace libtorrent {
|
|||
int len_dh = sizeof(m_dh_prime); // must equal DH_size(m_DH)
|
||||
if (key_size != len_dh)
|
||||
{
|
||||
assert(key_size > 0 && key_size < len_dh);
|
||||
TORRENT_ASSERT(key_size > 0 && key_size < len_dh);
|
||||
|
||||
int pad_zero_size = len_dh - key_size;
|
||||
std::fill(m_dh_local_key, m_dh_local_key + pad_zero_size, 0);
|
||||
|
@ -100,7 +100,7 @@ namespace libtorrent {
|
|||
|
||||
if (secret_size != 96)
|
||||
{
|
||||
assert(secret_size < 96 && secret_size > 0);
|
||||
TORRENT_ASSERT(secret_size < 96 && secret_size > 0);
|
||||
std::fill(m_dh_secret, m_dh_secret + 96 - secret_size, 0);
|
||||
}
|
||||
std::copy(dh_secret, dh_secret + secret_size, m_dh_secret + 96 - secret_size);
|
||||
|
|
|
@ -119,6 +119,7 @@ namespace libtorrent
|
|||
, m_remote_dl_rate(0)
|
||||
, m_remote_dl_update(time_now())
|
||||
, m_outstanding_writing_bytes(0)
|
||||
, m_fast_reconnect(false)
|
||||
#ifndef NDEBUG
|
||||
, m_in_constructor(true)
|
||||
#endif
|
||||
|
@ -133,7 +134,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
std::fill(m_peer_id.begin(), m_peer_id.end(), 0);
|
||||
|
||||
if (t->ready_for_connections())
|
||||
|
@ -195,6 +196,7 @@ namespace libtorrent
|
|||
, m_remote_dl_rate(0)
|
||||
, m_remote_dl_update(time_now())
|
||||
, m_outstanding_writing_bytes(0)
|
||||
, m_fast_reconnect(false)
|
||||
#ifndef NDEBUG
|
||||
, m_in_constructor(true)
|
||||
#endif
|
||||
|
@ -207,7 +209,7 @@ namespace libtorrent
|
|||
m_remote = m_socket->remote_endpoint();
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
assert(m_socket->remote_endpoint() == remote());
|
||||
TORRENT_ASSERT(m_socket->remote_endpoint() == remote());
|
||||
m_logger = m_ses.create_log(remote().address().to_string() + "_"
|
||||
+ boost::lexical_cast<std::string>(remote().port()), m_ses.listen_port());
|
||||
(*m_logger) << "*** INCOMING CONNECTION\n";
|
||||
|
@ -221,7 +223,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
bool interested = false;
|
||||
const std::vector<bool>& we_have = t->pieces();
|
||||
|
@ -245,7 +247,7 @@ namespace libtorrent
|
|||
// may throw an asio error if socket has disconnected
|
||||
catch (std::exception& e) {}
|
||||
|
||||
assert(is_interesting() == interested);
|
||||
TORRENT_ASSERT(is_interesting() == interested);
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
|
@ -260,7 +262,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
int num_allowed_pieces = m_ses.settings().allowed_fast_set_size;
|
||||
int num_pieces = t->torrent_file().num_pieces();
|
||||
|
@ -321,9 +323,9 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
assert(t->valid_metadata());
|
||||
assert(t->ready_for_connections());
|
||||
TORRENT_ASSERT(t);
|
||||
TORRENT_ASSERT(t->valid_metadata());
|
||||
TORRENT_ASSERT(t->ready_for_connections());
|
||||
|
||||
m_have_piece.resize(t->torrent_file().num_pieces(), m_have_all);
|
||||
|
||||
|
@ -374,7 +376,7 @@ namespace libtorrent
|
|||
peer_connection::~peer_connection()
|
||||
{
|
||||
// INVARIANT_CHECK;
|
||||
assert(m_disconnecting);
|
||||
TORRENT_ASSERT(m_disconnecting);
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
if (m_logger)
|
||||
|
@ -385,10 +387,10 @@ namespace libtorrent
|
|||
#endif
|
||||
#ifndef NDEBUG
|
||||
if (m_peer_info)
|
||||
assert(m_peer_info->connection == 0);
|
||||
TORRENT_ASSERT(m_peer_info->connection == 0);
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
if (t) assert(t->connection_for(remote()) != this);
|
||||
if (t) TORRENT_ASSERT(t->connection_for(remote()) != this);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -414,8 +416,8 @@ namespace libtorrent
|
|||
write_have(index);
|
||||
#ifndef NDEBUG
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
assert(t->have_piece(index));
|
||||
TORRENT_ASSERT(t);
|
||||
TORRENT_ASSERT(t->have_piece(index));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -424,10 +426,10 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
assert(t->valid_metadata());
|
||||
assert(i >= 0);
|
||||
assert(i < t->torrent_file().num_pieces());
|
||||
TORRENT_ASSERT(t);
|
||||
TORRENT_ASSERT(t->valid_metadata());
|
||||
TORRENT_ASSERT(i >= 0);
|
||||
TORRENT_ASSERT(i < t->torrent_file().num_pieces());
|
||||
return m_have_piece[i];
|
||||
}
|
||||
|
||||
|
@ -514,9 +516,9 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
assert(t->valid_metadata());
|
||||
TORRENT_ASSERT(t->valid_metadata());
|
||||
torrent_info const& ti = t->torrent_file();
|
||||
|
||||
return p.piece >= 0
|
||||
|
@ -539,8 +541,8 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!m_disconnecting);
|
||||
assert(m_torrent.expired());
|
||||
TORRENT_ASSERT(!m_disconnecting);
|
||||
TORRENT_ASSERT(m_torrent.expired());
|
||||
boost::weak_ptr<torrent> wpt = m_ses.find_torrent(ih);
|
||||
boost::shared_ptr<torrent> t = wpt.lock();
|
||||
|
||||
|
@ -578,27 +580,27 @@ namespace libtorrent
|
|||
throw std::runtime_error("connection rejected by paused torrent");
|
||||
}
|
||||
|
||||
assert(m_torrent.expired());
|
||||
TORRENT_ASSERT(m_torrent.expired());
|
||||
// check to make sure we don't have another connection with the same
|
||||
// info_hash and peer_id. If we do. close this connection.
|
||||
t->attach_peer(this);
|
||||
m_torrent = wpt;
|
||||
|
||||
assert(!m_torrent.expired());
|
||||
TORRENT_ASSERT(!m_torrent.expired());
|
||||
|
||||
// if the torrent isn't ready to accept
|
||||
// connections yet, we'll have to wait with
|
||||
// our initialization
|
||||
if (t->ready_for_connections()) init();
|
||||
|
||||
assert(!m_torrent.expired());
|
||||
TORRENT_ASSERT(!m_torrent.expired());
|
||||
|
||||
// assume the other end has no pieces
|
||||
// if we don't have valid metadata yet,
|
||||
// leave the vector unallocated
|
||||
assert(m_num_pieces == 0);
|
||||
TORRENT_ASSERT(m_num_pieces == 0);
|
||||
std::fill(m_have_piece.begin(), m_have_piece.end(), false);
|
||||
assert(!m_torrent.expired());
|
||||
TORRENT_ASSERT(!m_torrent.expired());
|
||||
}
|
||||
|
||||
// message handlers
|
||||
|
@ -625,7 +627,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
|
@ -681,7 +683,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
|
@ -801,7 +803,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
|
@ -827,7 +829,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
|
@ -862,16 +864,12 @@ namespace libtorrent
|
|||
|
||||
m_became_uninterested = time_now();
|
||||
|
||||
// clear the request queue if the client isn't interested
|
||||
m_requests.clear();
|
||||
// setup_send();
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << time_now_string() << " <== NOT_INTERESTED\n";
|
||||
#endif
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
m_peer_interested = false;
|
||||
t->get_policy().not_interested(*this);
|
||||
|
@ -886,7 +884,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
|
@ -944,7 +942,7 @@ namespace libtorrent
|
|||
|
||||
if (is_seed())
|
||||
{
|
||||
assert(m_peer_info);
|
||||
TORRENT_ASSERT(m_peer_info);
|
||||
m_peer_info->seed = true;
|
||||
if (t->is_finished())
|
||||
{
|
||||
|
@ -963,7 +961,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
|
@ -1006,7 +1004,7 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
assert(t->valid_metadata());
|
||||
TORRENT_ASSERT(t->valid_metadata());
|
||||
|
||||
int num_pieces = std::count(bitfield.begin(), bitfield.end(), true);
|
||||
if (num_pieces == int(m_have_piece.size()))
|
||||
|
@ -1087,7 +1085,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
|
@ -1225,7 +1223,7 @@ namespace libtorrent
|
|||
for (std::vector<piece_picker::downloading_piece>::const_iterator i =
|
||||
dl_queue.begin(); i != dl_queue.end(); ++i)
|
||||
{
|
||||
assert(i->finished <= blocks_per_piece);
|
||||
TORRENT_ASSERT(i->finished <= blocks_per_piece);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1244,7 +1242,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
|
@ -1292,8 +1290,8 @@ namespace libtorrent
|
|||
|
||||
std::vector<piece_block> finished_blocks;
|
||||
piece_block block_finished(p.piece, p.start / t->block_size());
|
||||
assert(p.start % t->block_size() == 0);
|
||||
assert(p.length == t->block_size()
|
||||
TORRENT_ASSERT(p.start % t->block_size() == 0);
|
||||
TORRENT_ASSERT(p.length == t->block_size()
|
||||
|| p.length == t->torrent_file().total_size() % t->block_size());
|
||||
|
||||
std::deque<piece_block>::iterator b
|
||||
|
@ -1366,7 +1364,7 @@ namespace libtorrent
|
|||
fs.async_write(p, data, bind(&peer_connection::on_disk_write_complete
|
||||
, self(), _1, _2, p, t));
|
||||
m_outstanding_writing_bytes += p.length;
|
||||
assert(!m_reading);
|
||||
TORRENT_ASSERT(!m_reading);
|
||||
picker.mark_as_writing(block_finished, peer_info_struct());
|
||||
}
|
||||
|
||||
|
@ -1376,7 +1374,7 @@ namespace libtorrent
|
|||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
m_outstanding_writing_bytes -= p.length;
|
||||
assert(m_outstanding_writing_bytes >= 0);
|
||||
TORRENT_ASSERT(m_outstanding_writing_bytes >= 0);
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << " *** on_disk_write_complete() " << p.length << "\n";
|
||||
|
@ -1406,8 +1404,8 @@ namespace libtorrent
|
|||
|
||||
piece_picker& picker = t->picker();
|
||||
|
||||
assert(p.piece == j.piece);
|
||||
assert(p.start == j.offset);
|
||||
TORRENT_ASSERT(p.piece == j.piece);
|
||||
TORRENT_ASSERT(p.start == j.offset);
|
||||
piece_block block_finished(p.piece, p.start / t->block_size());
|
||||
picker.mark_as_finished(block_finished, peer_info_struct());
|
||||
if (t->alerts().should_post(alert::debug))
|
||||
|
@ -1443,7 +1441,7 @@ namespace libtorrent
|
|||
catch (std::exception const& e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1511,7 +1509,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << time_now_string() << " <== HAVE_ALL\n";
|
||||
|
@ -1549,7 +1547,7 @@ namespace libtorrent
|
|||
if (t->is_finished())
|
||||
throw protocol_error("seed to seed connection redundant, disconnecting");
|
||||
|
||||
assert(!m_have_piece.empty());
|
||||
TORRENT_ASSERT(!m_have_piece.empty());
|
||||
std::fill(m_have_piece.begin(), m_have_piece.end(), true);
|
||||
m_num_pieces = m_have_piece.size();
|
||||
|
||||
|
@ -1567,7 +1565,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << time_now_string() << " <== HAVE_NONE\n";
|
||||
|
@ -1582,7 +1580,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
if (m_peer_info) m_peer_info->seed = false;
|
||||
assert(!m_have_piece.empty() || !t->ready_for_connections());
|
||||
TORRENT_ASSERT(!m_have_piece.empty() || !t->ready_for_connections());
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
|
@ -1594,7 +1592,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << time_now_string() << " <== ALLOWED_FAST [ " << index << " ]\n";
|
||||
|
@ -1641,7 +1639,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
m_allowed_fast.erase(std::remove_if(m_allowed_fast.begin()
|
||||
, m_allowed_fast.end(), bind(&torrent::have_piece, t, _1))
|
||||
|
@ -1656,15 +1654,15 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
assert(t->valid_metadata());
|
||||
assert(block.piece_index >= 0);
|
||||
assert(block.piece_index < t->torrent_file().num_pieces());
|
||||
assert(block.block_index >= 0);
|
||||
assert(block.block_index < t->torrent_file().piece_size(block.piece_index));
|
||||
assert(!t->picker().is_requested(block) || (t->picker().num_peers(block) > 0));
|
||||
assert(!t->have_piece(block.piece_index));
|
||||
TORRENT_ASSERT(t->valid_metadata());
|
||||
TORRENT_ASSERT(block.piece_index >= 0);
|
||||
TORRENT_ASSERT(block.piece_index < t->torrent_file().num_pieces());
|
||||
TORRENT_ASSERT(block.block_index >= 0);
|
||||
TORRENT_ASSERT(block.block_index < t->torrent_file().piece_size(block.piece_index));
|
||||
TORRENT_ASSERT(!t->picker().is_requested(block) || (t->picker().num_peers(block) > 0));
|
||||
TORRENT_ASSERT(!t->have_piece(block.piece_index));
|
||||
|
||||
piece_picker::piece_state_t state;
|
||||
peer_speed_t speed = peer_speed();
|
||||
|
@ -1702,14 +1700,14 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
assert(t->valid_metadata());
|
||||
TORRENT_ASSERT(t->valid_metadata());
|
||||
|
||||
assert(block.piece_index >= 0);
|
||||
assert(block.piece_index < t->torrent_file().num_pieces());
|
||||
assert(block.block_index >= 0);
|
||||
assert(block.block_index < t->torrent_file().piece_size(block.piece_index));
|
||||
TORRENT_ASSERT(block.piece_index >= 0);
|
||||
TORRENT_ASSERT(block.piece_index < t->torrent_file().num_pieces());
|
||||
TORRENT_ASSERT(block.block_index >= 0);
|
||||
TORRENT_ASSERT(block.block_index < t->torrent_file().piece_size(block.piece_index));
|
||||
|
||||
// if all the peers that requested this block has been
|
||||
// cancelled, then just ignore the cancel.
|
||||
|
@ -1741,8 +1739,8 @@ namespace libtorrent
|
|||
int block_size
|
||||
= (std::min)((int)t->torrent_file().piece_size(block.piece_index)-block_offset,
|
||||
t->block_size());
|
||||
assert(block_size > 0);
|
||||
assert(block_size <= t->block_size());
|
||||
TORRENT_ASSERT(block_size > 0);
|
||||
TORRENT_ASSERT(block_size <= t->block_size());
|
||||
|
||||
peer_request r;
|
||||
r.piece = block.piece_index;
|
||||
|
@ -1762,7 +1760,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!m_peer_info || !m_peer_info->optimistically_unchoked);
|
||||
TORRENT_ASSERT(!m_peer_info || !m_peer_info->optimistically_unchoked);
|
||||
|
||||
if (m_choked) return;
|
||||
write_choke();
|
||||
|
@ -1775,6 +1773,10 @@ namespace libtorrent
|
|||
m_last_choke = time_now();
|
||||
#endif
|
||||
m_num_invalid_requests = 0;
|
||||
|
||||
// reject the requests we have in the queue
|
||||
std::for_each(m_requests.begin(), m_requests.end()
|
||||
, bind(&peer_connection::write_reject_request, this, _1));
|
||||
m_requests.clear();
|
||||
}
|
||||
|
||||
|
@ -1825,7 +1827,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
if ((int)m_download_queue.size() >= m_desired_queue_size) return;
|
||||
|
||||
|
@ -1837,8 +1839,8 @@ namespace libtorrent
|
|||
int block_offset = block.block_index * t->block_size();
|
||||
int block_size = (std::min)((int)t->torrent_file().piece_size(
|
||||
block.piece_index) - block_offset, t->block_size());
|
||||
assert(block_size > 0);
|
||||
assert(block_size <= t->block_size());
|
||||
TORRENT_ASSERT(block_size > 0);
|
||||
TORRENT_ASSERT(block_size <= t->block_size());
|
||||
|
||||
peer_request r;
|
||||
r.piece = block.piece_index;
|
||||
|
@ -1883,14 +1885,14 @@ namespace libtorrent
|
|||
block_offset = block.block_index * t->block_size();
|
||||
block_size = (std::min)((int)t->torrent_file().piece_size(
|
||||
block.piece_index) - block_offset, t->block_size());
|
||||
assert(block_size > 0);
|
||||
assert(block_size <= t->block_size());
|
||||
TORRENT_ASSERT(block_size > 0);
|
||||
TORRENT_ASSERT(block_size <= t->block_size());
|
||||
|
||||
r.length += block_size;
|
||||
}
|
||||
}
|
||||
|
||||
assert(verify_piece(r));
|
||||
TORRENT_ASSERT(verify_piece(r));
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
bool handled = false;
|
||||
|
@ -1982,7 +1984,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::set_upload_limit(int limit)
|
||||
{
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
if (limit == -1) limit = (std::numeric_limits<int>::max)();
|
||||
if (limit < 10) limit = 10;
|
||||
m_upload_limit = limit;
|
||||
|
@ -1991,7 +1993,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::set_download_limit(int limit)
|
||||
{
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
if (limit == -1) limit = (std::numeric_limits<int>::max)();
|
||||
if (limit < 10) limit = 10;
|
||||
m_download_limit = limit;
|
||||
|
@ -2003,7 +2005,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
float ratio = t->ratio();
|
||||
|
||||
|
@ -2028,7 +2030,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::get_peer_info(peer_info& p) const
|
||||
{
|
||||
assert(!associated_torrent().expired());
|
||||
TORRENT_ASSERT(!associated_torrent().expired());
|
||||
|
||||
p.down_speed = statistics().download_rate();
|
||||
p.up_speed = statistics().upload_rate();
|
||||
|
@ -2111,10 +2113,10 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(packet_size > 0);
|
||||
assert(int(m_recv_buffer.size()) >= size);
|
||||
assert(int(m_recv_buffer.size()) >= m_recv_pos);
|
||||
assert(m_recv_pos >= size);
|
||||
TORRENT_ASSERT(packet_size > 0);
|
||||
TORRENT_ASSERT(int(m_recv_buffer.size()) >= size);
|
||||
TORRENT_ASSERT(int(m_recv_buffer.size()) >= m_recv_pos);
|
||||
TORRENT_ASSERT(m_recv_pos >= size);
|
||||
|
||||
if (size > 0)
|
||||
std::memmove(&m_recv_buffer[0], &m_recv_buffer[0] + size, m_recv_pos - size);
|
||||
|
@ -2139,7 +2141,7 @@ namespace libtorrent
|
|||
ptime now(time_now());
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
on_tick();
|
||||
|
||||
|
@ -2168,7 +2170,7 @@ namespace libtorrent
|
|||
// torrent for it
|
||||
const int block_size = m_request_large_blocks
|
||||
? t->torrent_file().piece_length() : t->block_size();
|
||||
assert(block_size > 0);
|
||||
TORRENT_ASSERT(block_size > 0);
|
||||
|
||||
m_desired_queue_size = static_cast<int>(queue_time
|
||||
* statistics().download_rate() / block_size);
|
||||
|
@ -2302,14 +2304,14 @@ namespace libtorrent
|
|||
&& (send_buffer_size() + m_reading_bytes < buffer_size_watermark)
|
||||
&& !m_choked)
|
||||
{
|
||||
assert(t->valid_metadata());
|
||||
TORRENT_ASSERT(t->valid_metadata());
|
||||
peer_request& r = m_requests.front();
|
||||
|
||||
assert(r.piece >= 0);
|
||||
assert(r.piece < (int)m_have_piece.size());
|
||||
assert(t->have_piece(r.piece));
|
||||
assert(r.start + r.length <= t->torrent_file().piece_size(r.piece));
|
||||
assert(r.length > 0 && r.start >= 0);
|
||||
TORRENT_ASSERT(r.piece >= 0);
|
||||
TORRENT_ASSERT(r.piece < (int)m_have_piece.size());
|
||||
TORRENT_ASSERT(t->have_piece(r.piece));
|
||||
TORRENT_ASSERT(r.start + r.length <= t->torrent_file().piece_size(r.piece));
|
||||
TORRENT_ASSERT(r.length > 0 && r.start >= 0);
|
||||
|
||||
t->filesystem().async_read(r, bind(&peer_connection::on_disk_read_complete
|
||||
, self(), _1, _2, r));
|
||||
|
@ -2369,13 +2371,13 @@ namespace libtorrent
|
|||
m_bandwidth_limit[channel].assign(amount);
|
||||
if (channel == upload_channel)
|
||||
{
|
||||
assert(m_writing);
|
||||
TORRENT_ASSERT(m_writing);
|
||||
m_writing = false;
|
||||
setup_send();
|
||||
}
|
||||
else if (channel == download_channel)
|
||||
{
|
||||
assert(m_reading);
|
||||
TORRENT_ASSERT(m_reading);
|
||||
m_reading = false;
|
||||
setup_receive();
|
||||
}
|
||||
|
@ -2415,14 +2417,14 @@ namespace libtorrent
|
|||
// in this case, we have data to send, but no
|
||||
// bandwidth. So, we simply request bandwidth
|
||||
// from the torrent
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
if (m_bandwidth_limit[upload_channel].max_assignable() > 0)
|
||||
{
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << "req bandwidth [ " << upload_channel << " ]\n";
|
||||
#endif
|
||||
|
||||
assert(!m_writing);
|
||||
TORRENT_ASSERT(!m_writing);
|
||||
// peers that we are not interested in are non-prioritized
|
||||
m_writing = true;
|
||||
t->request_bandwidth(upload_channel, self()
|
||||
|
@ -2433,7 +2435,7 @@ namespace libtorrent
|
|||
|
||||
if (!can_write()) return;
|
||||
|
||||
assert(!m_writing);
|
||||
TORRENT_ASSERT(!m_writing);
|
||||
|
||||
// send the actual buffer
|
||||
if (!m_send_buffer.empty())
|
||||
|
@ -2443,7 +2445,7 @@ namespace libtorrent
|
|||
if (!m_ignore_bandwidth_limits && amount_to_send > quota_left)
|
||||
amount_to_send = quota_left;
|
||||
|
||||
assert(amount_to_send > 0);
|
||||
TORRENT_ASSERT(amount_to_send > 0);
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << "async_write " << amount_to_send << " bytes\n";
|
||||
|
@ -2486,7 +2488,7 @@ namespace libtorrent
|
|||
|
||||
if (!can_read()) return;
|
||||
|
||||
assert(m_packet_size > 0);
|
||||
TORRENT_ASSERT(m_packet_size > 0);
|
||||
int max_receive = m_packet_size - m_recv_pos;
|
||||
int quota_left = m_bandwidth_limit[download_channel].quota_left();
|
||||
if (!m_ignore_bandwidth_limits && max_receive > quota_left)
|
||||
|
@ -2494,10 +2496,10 @@ namespace libtorrent
|
|||
|
||||
if (max_receive == 0) return;
|
||||
|
||||
assert(m_recv_pos >= 0);
|
||||
assert(m_packet_size > 0);
|
||||
TORRENT_ASSERT(m_recv_pos >= 0);
|
||||
TORRENT_ASSERT(m_packet_size > 0);
|
||||
|
||||
assert(can_read());
|
||||
TORRENT_ASSERT(can_read());
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << "async_read " << max_receive << " bytes\n";
|
||||
#endif
|
||||
|
@ -2508,7 +2510,7 @@ namespace libtorrent
|
|||
|
||||
void peer_connection::reset_recv_buffer(int packet_size)
|
||||
{
|
||||
assert(packet_size > 0);
|
||||
TORRENT_ASSERT(packet_size > 0);
|
||||
if (m_recv_pos > m_packet_size)
|
||||
{
|
||||
cut_receive_buffer(m_packet_size, packet_size);
|
||||
|
@ -2538,7 +2540,7 @@ namespace libtorrent
|
|||
if (size <= 0) return;
|
||||
|
||||
std::pair<char*, int> buffer = m_ses.allocate_buffer(size);
|
||||
assert(buffer.second >= size);
|
||||
TORRENT_ASSERT(buffer.second >= size);
|
||||
std::memcpy(buffer.first, buf, size);
|
||||
m_send_buffer.append_buffer(buffer.first, buffer.second, size
|
||||
, bind(&session_impl::free_buffer, boost::ref(m_ses), _1, buffer.second));
|
||||
|
@ -2557,7 +2559,7 @@ namespace libtorrent
|
|||
if (insert == 0)
|
||||
{
|
||||
std::pair<char*, int> buffer = m_ses.allocate_buffer(size);
|
||||
assert(buffer.second >= size);
|
||||
TORRENT_ASSERT(buffer.second >= size);
|
||||
m_send_buffer.append_buffer(buffer.first, buffer.second, size
|
||||
, bind(&session_impl::free_buffer, boost::ref(m_ses), _1, buffer.second));
|
||||
buffer::interval ret(buffer.first, buffer.first + size);
|
||||
|
@ -2601,7 +2603,7 @@ namespace libtorrent
|
|||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_reading);
|
||||
TORRENT_ASSERT(m_reading);
|
||||
m_reading = false;
|
||||
|
||||
if (error)
|
||||
|
@ -2624,16 +2626,16 @@ namespace libtorrent
|
|||
|
||||
if (m_disconnecting) return;
|
||||
|
||||
assert(m_packet_size > 0);
|
||||
assert(bytes_transferred > 0);
|
||||
TORRENT_ASSERT(m_packet_size > 0);
|
||||
TORRENT_ASSERT(bytes_transferred > 0);
|
||||
|
||||
m_last_receive = time_now();
|
||||
m_recv_pos += bytes_transferred;
|
||||
assert(m_recv_pos <= int(m_recv_buffer.size()));
|
||||
TORRENT_ASSERT(m_recv_pos <= int(m_recv_buffer.size()));
|
||||
|
||||
on_receive(error, bytes_transferred);
|
||||
|
||||
assert(m_packet_size > 0);
|
||||
TORRENT_ASSERT(m_packet_size > 0);
|
||||
|
||||
if (m_peer_choked
|
||||
&& m_recv_pos == 0
|
||||
|
@ -2686,7 +2688,7 @@ namespace libtorrent
|
|||
catch (...)
|
||||
{
|
||||
// all exceptions should derive from std::exception
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
m_ses.connection_failed(m_socket, remote(), "connection failed for unknown reason");
|
||||
}
|
||||
|
@ -2731,10 +2733,10 @@ namespace libtorrent
|
|||
|
||||
m_connection_ticket = ticket;
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
m_queued = false;
|
||||
assert(m_connecting);
|
||||
TORRENT_ASSERT(m_connecting);
|
||||
m_socket->open(t->get_interface().protocol());
|
||||
|
||||
// set the socket to non-blocking, so that we can
|
||||
|
@ -2794,7 +2796,7 @@ namespace libtorrent
|
|||
catch (...)
|
||||
{
|
||||
// all exceptions should derive from std::exception
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
m_ses.connection_failed(m_socket, remote(), "connection failed for unkown reason");
|
||||
}
|
||||
|
@ -2811,7 +2813,7 @@ namespace libtorrent
|
|||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_writing);
|
||||
TORRENT_ASSERT(m_writing);
|
||||
|
||||
m_send_buffer.pop_front(bytes_transferred);
|
||||
|
||||
|
@ -2833,8 +2835,8 @@ namespace libtorrent
|
|||
}
|
||||
if (m_disconnecting) return;
|
||||
|
||||
assert(!m_connecting);
|
||||
assert(bytes_transferred > 0);
|
||||
TORRENT_ASSERT(!m_connecting);
|
||||
TORRENT_ASSERT(bytes_transferred > 0);
|
||||
|
||||
m_last_sent = time_now();
|
||||
|
||||
|
@ -2851,7 +2853,7 @@ namespace libtorrent
|
|||
catch (...)
|
||||
{
|
||||
// all exceptions should derive from std::exception
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
m_ses.connection_failed(m_socket, remote(), "connection failed for unknown reason");
|
||||
}
|
||||
|
@ -2862,11 +2864,11 @@ namespace libtorrent
|
|||
{
|
||||
if (m_peer_info)
|
||||
{
|
||||
assert(m_peer_info->connection == this
|
||||
TORRENT_ASSERT(m_peer_info->connection == this
|
||||
|| m_peer_info->connection == 0);
|
||||
|
||||
if (m_peer_info->optimistically_unchoked)
|
||||
assert(!is_choked());
|
||||
TORRENT_ASSERT(!is_choked());
|
||||
}
|
||||
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
|
@ -2877,17 +2879,17 @@ namespace libtorrent
|
|||
for (torrent_map::iterator i = m.begin(), end(m.end()); i != end; ++i)
|
||||
{
|
||||
torrent& t = *i->second;
|
||||
assert(t.connection_for(m_remote) != this);
|
||||
TORRENT_ASSERT(t.connection_for(m_remote) != this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
assert(t->connection_for(remote()) != 0 || m_in_constructor);
|
||||
TORRENT_ASSERT(t->connection_for(remote()) != 0 || m_in_constructor);
|
||||
|
||||
if (!m_in_constructor && t->connection_for(remote()) != this
|
||||
&& !m_ses.settings().allow_multiple_connections_per_ip)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
||||
// expensive when using checked iterators
|
||||
|
@ -2898,7 +2900,7 @@ namespace libtorrent
|
|||
, m_have_piece.end(), true);
|
||||
if (m_num_pieces != piece_count)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -2923,11 +2925,11 @@ namespace libtorrent
|
|||
std::find(m_download_queue.begin(), m_download_queue.end()
|
||||
, piece_block(i->index, j)) != m_download_queue.end())
|
||||
{
|
||||
assert(i->info[j].peer == m_remote);
|
||||
TORRENT_ASSERT(i->info[j].peer == m_remote);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(i->info[j].peer != m_remote || i->info[j].finished);
|
||||
TORRENT_ASSERT(i->info[j].peer != m_remote || i->info[j].finished);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2997,7 +2999,7 @@ namespace libtorrent
|
|||
peer_connection::peer_speed_t peer_connection::peer_speed()
|
||||
{
|
||||
shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
int download_rate = int(statistics().download_payload_rate());
|
||||
int torrent_download_rate = int(t->statistics().download_payload_rate());
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -83,16 +83,16 @@ namespace
|
|||
// (and we should not consider it free). If the share diff is
|
||||
// negative, there's no free download to get from this peer.
|
||||
size_type diff = i->second->share_diff();
|
||||
assert(diff < (std::numeric_limits<size_type>::max)());
|
||||
TORRENT_ASSERT(diff < (std::numeric_limits<size_type>::max)());
|
||||
if (i->second->is_peer_interested() || diff <= 0)
|
||||
continue;
|
||||
|
||||
assert(diff > 0);
|
||||
TORRENT_ASSERT(diff > 0);
|
||||
i->second->add_free_upload(-diff);
|
||||
accumulator += diff;
|
||||
assert(accumulator > 0);
|
||||
TORRENT_ASSERT(accumulator > 0);
|
||||
}
|
||||
assert(accumulator >= 0);
|
||||
TORRENT_ASSERT(accumulator >= 0);
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ namespace
|
|||
for (torrent::peer_iterator i = start; i != end; ++i)
|
||||
{
|
||||
size_type d = i->second->share_diff();
|
||||
assert(d < (std::numeric_limits<size_type>::max)());
|
||||
TORRENT_ASSERT(d < (std::numeric_limits<size_type>::max)());
|
||||
total_diff += d;
|
||||
if (!i->second->is_peer_interested() || i->second->share_diff() >= 0) continue;
|
||||
++num_peers;
|
||||
|
@ -191,8 +191,8 @@ namespace libtorrent
|
|||
{
|
||||
if (t.is_seed()) return;
|
||||
|
||||
assert(t.valid_metadata());
|
||||
assert(c.peer_info_struct() != 0 || !dynamic_cast<bt_peer_connection*>(&c));
|
||||
TORRENT_ASSERT(t.valid_metadata());
|
||||
TORRENT_ASSERT(c.peer_info_struct() != 0 || !dynamic_cast<bt_peer_connection*>(&c));
|
||||
int num_requests = c.desired_queue_size()
|
||||
- (int)c.download_queue().size()
|
||||
- (int)c.request_queue().size();
|
||||
|
@ -200,7 +200,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*c.m_logger) << time_now_string() << " PIECE_PICKER [ req: " << num_requests << " ]\n";
|
||||
#endif
|
||||
assert(c.desired_queue_size() > 0);
|
||||
TORRENT_ASSERT(c.desired_queue_size() > 0);
|
||||
// if our request queue is already full, we
|
||||
// don't have to make any new requests yet
|
||||
if (num_requests <= 0) return;
|
||||
|
@ -224,7 +224,7 @@ namespace libtorrent
|
|||
// the number of blocks we want, but it will try to make the picked
|
||||
// blocks be from whole pieces, possibly by returning more blocks
|
||||
// than we requested.
|
||||
assert(c.remote() == c.get_socket()->remote_endpoint());
|
||||
TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint());
|
||||
|
||||
piece_picker::piece_state_t state;
|
||||
peer_connection::peer_speed_t speed = c.peer_speed();
|
||||
|
@ -298,13 +298,13 @@ namespace libtorrent
|
|||
continue;
|
||||
}
|
||||
|
||||
assert(p.num_peers(*i) == 0);
|
||||
TORRENT_ASSERT(p.num_peers(*i) == 0);
|
||||
// ok, we found a piece that's not being downloaded
|
||||
// by somebody else. request it from this peer
|
||||
// and return
|
||||
c.add_request(*i);
|
||||
assert(p.num_peers(*i) == 1);
|
||||
assert(p.is_requested(*i));
|
||||
TORRENT_ASSERT(p.num_peers(*i) == 1);
|
||||
TORRENT_ASSERT(p.is_requested(*i));
|
||||
num_requests--;
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
piece_picker::downloading_piece st;
|
||||
p.piece_info(i->piece_index, st);
|
||||
assert(st.requested + st.finished + st.writing == p.blocks_in_piece(i->piece_index));
|
||||
TORRENT_ASSERT(st.requested + st.finished + st.writing == p.blocks_in_piece(i->piece_index));
|
||||
#endif
|
||||
c.add_request(*i);
|
||||
c.send_block_requests();
|
||||
|
@ -341,7 +341,7 @@ namespace libtorrent
|
|||
: m_torrent(t)
|
||||
, m_available_free_upload(0)
|
||||
// , m_last_optimistic_disconnect(min_time())
|
||||
{ assert(t); }
|
||||
{ TORRENT_ASSERT(t); }
|
||||
|
||||
// disconnects and removes all peers that are now filtered
|
||||
void policy::ip_filter_updated()
|
||||
|
@ -367,7 +367,7 @@ namespace libtorrent
|
|||
ses.m_alerts.post_alert(peer_blocked_alert(i->second.ip.address()
|
||||
, "disconnected blocked peer"));
|
||||
}
|
||||
assert(i->second.connection == 0
|
||||
TORRENT_ASSERT(i->second.connection == 0
|
||||
|| i->second.connection->peer_info_struct() == 0);
|
||||
}
|
||||
else
|
||||
|
@ -427,7 +427,7 @@ namespace libtorrent
|
|||
worst_peer = i;
|
||||
continue;
|
||||
}
|
||||
assert(unchoked_counter == 0);
|
||||
TORRENT_ASSERT(unchoked_counter == 0);
|
||||
return worst_peer;
|
||||
}
|
||||
|
||||
|
@ -538,7 +538,7 @@ namespace libtorrent
|
|||
if (ses.m_port_filter.access(i->second.ip.port()) & port_filter::blocked)
|
||||
continue;
|
||||
|
||||
assert(i->second.connected <= now);
|
||||
TORRENT_ASSERT(i->second.connected <= now);
|
||||
|
||||
if (i->second.connected <= min_connect_time)
|
||||
{
|
||||
|
@ -547,7 +547,7 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
assert(min_connect_time <= now);
|
||||
TORRENT_ASSERT(min_connect_time <= now);
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_num_unchoked > 0);
|
||||
TORRENT_ASSERT(m_num_unchoked > 0);
|
||||
// first choice candidate.
|
||||
// it is a candidate we owe nothing to and which has been unchoked
|
||||
// the longest.
|
||||
|
@ -604,7 +604,7 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
if (candidate != m_peers.end()) return candidate;
|
||||
assert(second_candidate != m_peers.end());
|
||||
TORRENT_ASSERT(second_candidate != m_peers.end());
|
||||
return second_candidate;
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,7 @@ namespace libtorrent
|
|||
iterator p = find_seed_unchoke_candidate();
|
||||
if (p != m_peers.end())
|
||||
{
|
||||
assert(p->connection->is_choked());
|
||||
TORRENT_ASSERT(p->connection->is_choked());
|
||||
p->connection->send_unchoke();
|
||||
p->last_optimistically_unchoked = time_now();
|
||||
++m_num_unchoked;
|
||||
|
@ -652,7 +652,7 @@ namespace libtorrent
|
|||
iterator p = find_seed_choke_candidate();
|
||||
if (p != m_peers.end())
|
||||
{
|
||||
assert(!p->connection->is_choked());
|
||||
TORRENT_ASSERT(!p->connection->is_choked());
|
||||
p->connection->send_choke();
|
||||
--m_num_unchoked;
|
||||
}
|
||||
|
@ -730,7 +730,7 @@ namespace libtorrent
|
|||
{
|
||||
bool ret = disconnect_one_peer();
|
||||
(void)ret;
|
||||
assert(ret);
|
||||
TORRENT_ASSERT(ret);
|
||||
--num_connected_peers;
|
||||
}
|
||||
}
|
||||
|
@ -777,10 +777,10 @@ namespace libtorrent
|
|||
{
|
||||
iterator p = find_seed_choke_candidate();
|
||||
--m_num_unchoked;
|
||||
assert(p != m_peers.end());
|
||||
TORRENT_ASSERT(p != m_peers.end());
|
||||
if (p == m_peers.end()) break;
|
||||
|
||||
assert(!p->connection->is_choked());
|
||||
TORRENT_ASSERT(!p->connection->is_choked());
|
||||
p->connection->send_choke();
|
||||
} while (m_num_unchoked > m_torrent->m_uploads_quota.given);
|
||||
}
|
||||
|
@ -790,11 +790,11 @@ namespace libtorrent
|
|||
// unchoked peer with one of the choked
|
||||
// TODO: This rotation should happen
|
||||
// far less frequent than this!
|
||||
assert(m_num_unchoked <= m_torrent->num_peers());
|
||||
TORRENT_ASSERT(m_num_unchoked <= m_torrent->num_peers());
|
||||
iterator p = find_seed_unchoke_candidate();
|
||||
if (p != m_peers.end())
|
||||
{
|
||||
assert(p->connection->is_choked());
|
||||
TORRENT_ASSERT(p->connection->is_choked());
|
||||
seed_choke_one_peer();
|
||||
p->connection->send_unchoke();
|
||||
++m_num_unchoked;
|
||||
|
@ -841,7 +841,7 @@ namespace libtorrent
|
|||
|
||||
if (m_torrent->m_uploads_quota.given < m_torrent->num_peers())
|
||||
{
|
||||
assert(m_torrent->m_uploads_quota.given >= 0);
|
||||
TORRENT_ASSERT(m_torrent->m_uploads_quota.given >= 0);
|
||||
|
||||
// make sure we don't have too many
|
||||
// unchoked peers
|
||||
|
@ -851,8 +851,8 @@ namespace libtorrent
|
|||
{
|
||||
iterator p = find_choke_candidate();
|
||||
if (p == m_peers.end()) break;
|
||||
assert(p != m_peers.end());
|
||||
assert(!p->connection->is_choked());
|
||||
TORRENT_ASSERT(p != m_peers.end());
|
||||
TORRENT_ASSERT(!p->connection->is_choked());
|
||||
p->connection->send_choke();
|
||||
--m_num_unchoked;
|
||||
} while (m_num_unchoked > m_torrent->m_uploads_quota.given);
|
||||
|
@ -864,11 +864,11 @@ namespace libtorrent
|
|||
{
|
||||
// optimistic unchoke. trade the 'worst'
|
||||
// unchoked peer with one of the choked
|
||||
assert(m_num_unchoked <= m_torrent->num_peers());
|
||||
TORRENT_ASSERT(m_num_unchoked <= m_torrent->num_peers());
|
||||
iterator p = find_unchoke_candidate();
|
||||
if (p != m_peers.end())
|
||||
{
|
||||
assert(p->connection->is_choked());
|
||||
TORRENT_ASSERT(p->connection->is_choked());
|
||||
choke_one_peer();
|
||||
p->connection->send_unchoke();
|
||||
++m_num_unchoked;
|
||||
|
@ -902,7 +902,7 @@ namespace libtorrent
|
|||
|
||||
void policy::new_connection(peer_connection& c)
|
||||
{
|
||||
assert(!c.is_local());
|
||||
TORRENT_ASSERT(!c.is_local());
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -912,7 +912,7 @@ namespace libtorrent
|
|||
|
||||
// TODO: only allow _one_ connection to use this
|
||||
// override at a time
|
||||
assert(c.remote() == c.get_socket()->remote_endpoint());
|
||||
TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint());
|
||||
|
||||
if (m_torrent->num_peers() >= m_torrent->max_connections()
|
||||
&& m_torrent->session().num_connections() >= m_torrent->session().max_connections()
|
||||
|
@ -949,7 +949,7 @@ namespace libtorrent
|
|||
|
||||
if (i->second.connection != 0)
|
||||
{
|
||||
assert(i->second.connection != &c);
|
||||
TORRENT_ASSERT(i->second.connection != &c);
|
||||
// the new connection is a local (outgoing) connection
|
||||
// or the current one is already connected
|
||||
if (!i->second.connection->is_connecting() || c.is_local())
|
||||
|
@ -971,21 +971,21 @@ namespace libtorrent
|
|||
{
|
||||
// we don't have any info about this peer.
|
||||
// add a new entry
|
||||
assert(c.remote() == c.get_socket()->remote_endpoint());
|
||||
TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint());
|
||||
|
||||
peer p(c.remote(), peer::not_connectable, 0);
|
||||
i = m_peers.insert(std::make_pair(c.remote().address(), p));
|
||||
}
|
||||
|
||||
assert(m_torrent->connection_for(c.remote()) == &c);
|
||||
TORRENT_ASSERT(m_torrent->connection_for(c.remote()) == &c);
|
||||
|
||||
c.set_peer_info(&i->second);
|
||||
assert(i->second.connection == 0);
|
||||
TORRENT_ASSERT(i->second.connection == 0);
|
||||
c.add_stat(i->second.prev_amount_download, i->second.prev_amount_upload);
|
||||
i->second.prev_amount_download = 0;
|
||||
i->second.prev_amount_upload = 0;
|
||||
i->second.connection = &c;
|
||||
assert(i->second.connection);
|
||||
TORRENT_ASSERT(i->second.connection);
|
||||
i->second.connected = time_now();
|
||||
// m_last_optimistic_disconnect = time_now();
|
||||
}
|
||||
|
@ -1094,7 +1094,7 @@ namespace libtorrent
|
|||
+ boost::lexical_cast<std::string>(remote.port()) + " "
|
||||
+ boost::lexical_cast<std::string>(i->second.connection->pid()));
|
||||
|
||||
assert(i->second.connection->associated_torrent().lock().get() == m_torrent);
|
||||
TORRENT_ASSERT(i->second.connection->associated_torrent().lock().get() == m_torrent);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1122,7 +1122,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(index >= 0 && index < m_torrent->torrent_file().num_pieces());
|
||||
TORRENT_ASSERT(index >= 0 && index < m_torrent->torrent_file().num_pieces());
|
||||
|
||||
if (successfully_verified)
|
||||
{
|
||||
|
@ -1157,7 +1157,7 @@ namespace libtorrent
|
|||
{
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(std::find_if(m_peers.begin(), m_peers.end()
|
||||
TORRENT_ASSERT(std::find_if(m_peers.begin(), m_peers.end()
|
||||
, boost::bind<bool>(std::equal_to<peer_connection*>(), bind(&peer::connection
|
||||
, bind(&iterator::value_type::second, _1)), &c)) != m_peers.end());
|
||||
|
||||
|
@ -1213,7 +1213,7 @@ namespace libtorrent
|
|||
|
||||
if (m_torrent->ratio() != 0.f)
|
||||
{
|
||||
assert(c.share_diff() < (std::numeric_limits<size_type>::max)());
|
||||
TORRENT_ASSERT(c.share_diff() < (std::numeric_limits<size_type>::max)());
|
||||
size_type diff = c.share_diff();
|
||||
if (diff > 0 && c.is_seed())
|
||||
{
|
||||
|
@ -1242,10 +1242,10 @@ namespace libtorrent
|
|||
|
||||
iterator p = find_unchoke_candidate();
|
||||
if (p == m_peers.end()) return false;
|
||||
assert(p->connection);
|
||||
assert(!p->connection->is_disconnecting());
|
||||
TORRENT_ASSERT(p->connection);
|
||||
TORRENT_ASSERT(!p->connection->is_disconnecting());
|
||||
|
||||
assert(p->connection->is_choked());
|
||||
TORRENT_ASSERT(p->connection->is_choked());
|
||||
p->connection->send_unchoke();
|
||||
p->last_optimistically_unchoked = time_now();
|
||||
++m_num_unchoked;
|
||||
|
@ -1258,9 +1258,9 @@ namespace libtorrent
|
|||
|
||||
iterator p = find_choke_candidate();
|
||||
if (p == m_peers.end()) return;
|
||||
assert(p->connection);
|
||||
assert(!p->connection->is_disconnecting());
|
||||
assert(!p->connection->is_choked());
|
||||
TORRENT_ASSERT(p->connection);
|
||||
TORRENT_ASSERT(!p->connection->is_disconnecting());
|
||||
TORRENT_ASSERT(!p->connection->is_choked());
|
||||
p->connection->send_choke();
|
||||
--m_num_unchoked;
|
||||
}
|
||||
|
@ -1269,20 +1269,20 @@ namespace libtorrent
|
|||
{
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(m_torrent->want_more_peers());
|
||||
TORRENT_ASSERT(m_torrent->want_more_peers());
|
||||
|
||||
iterator p = find_connect_candidate();
|
||||
if (p == m_peers.end()) return false;
|
||||
|
||||
assert(!p->second.banned);
|
||||
assert(!p->second.connection);
|
||||
assert(p->second.type == peer::connectable);
|
||||
TORRENT_ASSERT(!p->second.banned);
|
||||
TORRENT_ASSERT(!p->second.connection);
|
||||
TORRENT_ASSERT(p->second.type == peer::connectable);
|
||||
|
||||
try
|
||||
{
|
||||
p->second.connected = time_now();
|
||||
p->second.connection = m_torrent->connect_to_peer(&p->second);
|
||||
assert(p->second.connection == m_torrent->connection_for(p->second.ip));
|
||||
TORRENT_ASSERT(p->second.connection == m_torrent->connection_for(p->second.ip));
|
||||
if (p->second.connection == 0)
|
||||
{
|
||||
++p->second.failcount;
|
||||
|
@ -1326,7 +1326,7 @@ namespace libtorrent
|
|||
|
||||
peer* p = c.peer_info_struct();
|
||||
|
||||
assert((std::find_if(
|
||||
TORRENT_ASSERT((std::find_if(
|
||||
m_peers.begin()
|
||||
, m_peers.end()
|
||||
, match_peer_connection(c))
|
||||
|
@ -1335,11 +1335,15 @@ namespace libtorrent
|
|||
// if we couldn't find the connection in our list, just ignore it.
|
||||
if (p == 0) return;
|
||||
|
||||
assert(p->connection == &c);
|
||||
TORRENT_ASSERT(p->connection == &c);
|
||||
|
||||
p->connection = 0;
|
||||
p->optimistically_unchoked = false;
|
||||
|
||||
// if fast reconnect is true, we won't
|
||||
// update the timestamp, and it will remain
|
||||
// the time when we initiated the connection.
|
||||
if (!c.fast_reconnect())
|
||||
p->connected = time_now();
|
||||
|
||||
if (c.failed())
|
||||
|
@ -1353,8 +1357,8 @@ namespace libtorrent
|
|||
// because it isn't necessary.
|
||||
if (m_torrent->ratio() != 0.f)
|
||||
{
|
||||
assert(c.associated_torrent().lock().get() == m_torrent);
|
||||
assert(c.share_diff() < (std::numeric_limits<size_type>::max)());
|
||||
TORRENT_ASSERT(c.associated_torrent().lock().get() == m_torrent);
|
||||
TORRENT_ASSERT(c.share_diff() < (std::numeric_limits<size_type>::max)());
|
||||
m_available_free_upload += c.share_diff();
|
||||
}
|
||||
p->prev_amount_download += c.statistics().total_payload_download();
|
||||
|
@ -1378,8 +1382,8 @@ namespace libtorrent
|
|||
// too expensive
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(c);
|
||||
try { assert(c->remote() == c->get_socket()->remote_endpoint()); }
|
||||
TORRENT_ASSERT(c);
|
||||
try { TORRENT_ASSERT(c->remote() == c->get_socket()->remote_endpoint()); }
|
||||
catch (std::exception&) {}
|
||||
|
||||
return std::find_if(
|
||||
|
@ -1403,11 +1407,11 @@ namespace libtorrent
|
|||
peer const& p = i->second;
|
||||
if (!m_torrent->settings().allow_multiple_connections_per_ip)
|
||||
{
|
||||
assert(m_peers.count(p.ip.address()) == 1);
|
||||
TORRENT_ASSERT(m_peers.count(p.ip.address()) == 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(unique_test.count(p.ip) == 0);
|
||||
TORRENT_ASSERT(unique_test.count(p.ip) == 0);
|
||||
unique_test.insert(p.ip);
|
||||
}
|
||||
++total_connections;
|
||||
|
@ -1419,16 +1423,16 @@ namespace libtorrent
|
|||
{
|
||||
std::vector<peer_connection*> conns;
|
||||
m_torrent->connection_for(p.ip.address(), conns);
|
||||
assert(std::find_if(conns.begin(), conns.end()
|
||||
TORRENT_ASSERT(std::find_if(conns.begin(), conns.end()
|
||||
, boost::bind(std::equal_to<peer_connection*>(), _1, p.connection))
|
||||
!= conns.end());
|
||||
}
|
||||
if (p.optimistically_unchoked)
|
||||
{
|
||||
assert(p.connection);
|
||||
assert(!p.connection->is_choked());
|
||||
TORRENT_ASSERT(p.connection);
|
||||
TORRENT_ASSERT(!p.connection->is_choked());
|
||||
}
|
||||
assert(p.connection->peer_info_struct() == 0
|
||||
TORRENT_ASSERT(p.connection->peer_info_struct() == 0
|
||||
|| p.connection->peer_info_struct() == &p);
|
||||
++nonempty_connections;
|
||||
if (!p.connection->is_disconnecting())
|
||||
|
@ -1466,7 +1470,7 @@ namespace libtorrent
|
|||
{
|
||||
policy::peer* p = static_cast<policy::peer*>(*i);
|
||||
if (p == 0) continue;
|
||||
assert(std::find_if(m_peers.begin(), m_peers.end()
|
||||
TORRENT_ASSERT(std::find_if(m_peers.begin(), m_peers.end()
|
||||
, match_peer_connection(*p->connection)) != m_peers.end());
|
||||
}
|
||||
}
|
||||
|
@ -1480,7 +1484,7 @@ namespace libtorrent
|
|||
// be added to the torrent and then to the policy.
|
||||
// that's why the two second cases are in there.
|
||||
/*
|
||||
assert(connected_peers == num_torrent_peers
|
||||
TORRENT_ASSERT(connected_peers == num_torrent_peers
|
||||
|| (connected_peers == num_torrent_peers + 1
|
||||
&& connected_peers > 0)
|
||||
|| (connected_peers + 1 == num_torrent_peers
|
||||
|
@ -1509,14 +1513,14 @@ namespace libtorrent
|
|||
, source(src)
|
||||
, connection(0)
|
||||
{
|
||||
assert(connected < time_now());
|
||||
TORRENT_ASSERT(connected < time_now());
|
||||
}
|
||||
|
||||
size_type policy::peer::total_download() const
|
||||
{
|
||||
if (connection != 0)
|
||||
{
|
||||
assert(prev_amount_download == 0);
|
||||
TORRENT_ASSERT(prev_amount_download == 0);
|
||||
return connection->statistics().total_payload_download();
|
||||
}
|
||||
else
|
||||
|
@ -1529,7 +1533,7 @@ namespace libtorrent
|
|||
{
|
||||
if (connection != 0)
|
||||
{
|
||||
assert(prev_amount_upload == 0);
|
||||
TORRENT_ASSERT(prev_amount_upload == 0);
|
||||
return connection->statistics().total_payload_upload();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -110,14 +110,14 @@ namespace libtorrent
|
|||
: m_impl(new session_impl(listen_port_range, id, listen_interface))
|
||||
{
|
||||
// turn off the filename checking in boost.filesystem
|
||||
assert(listen_port_range.first > 0);
|
||||
assert(listen_port_range.first < listen_port_range.second);
|
||||
TORRENT_ASSERT(listen_port_range.first > 0);
|
||||
TORRENT_ASSERT(listen_port_range.first < listen_port_range.second);
|
||||
#ifndef NDEBUG
|
||||
// this test was added after it came to my attention
|
||||
// that devstudios managed c++ failed to generate
|
||||
// correct code for boost.function
|
||||
boost::function0<void> test = boost::ref(*m_impl);
|
||||
assert(!test.empty());
|
||||
TORRENT_ASSERT(!test.empty());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -126,13 +126,13 @@ namespace libtorrent
|
|||
{
|
||||
#ifndef NDEBUG
|
||||
boost::function0<void> test = boost::ref(*m_impl);
|
||||
assert(!test.empty());
|
||||
TORRENT_ASSERT(!test.empty());
|
||||
#endif
|
||||
}
|
||||
|
||||
session::~session()
|
||||
{
|
||||
assert(m_impl);
|
||||
TORRENT_ASSERT(m_impl);
|
||||
// if there is at least one destruction-proxy
|
||||
// abort the session and let the destructor
|
||||
// of the proxy to syncronize
|
||||
|
@ -190,7 +190,7 @@ namespace libtorrent
|
|||
, bool paused
|
||||
, storage_constructor_type sc)
|
||||
{
|
||||
assert(!ti.m_half_metadata);
|
||||
TORRENT_ASSERT(!ti.m_half_metadata);
|
||||
boost::intrusive_ptr<torrent_info> tip(new torrent_info(ti));
|
||||
return m_impl->add_torrent(tip, save_path, resume_data
|
||||
, compact_mode, sc, paused, 0);
|
||||
|
@ -205,7 +205,7 @@ namespace libtorrent
|
|||
, storage_constructor_type sc
|
||||
, void* userdata)
|
||||
{
|
||||
assert(!ti->m_half_metadata);
|
||||
TORRENT_ASSERT(!ti->m_half_metadata);
|
||||
return m_impl->add_torrent(ti, save_path, resume_data
|
||||
, compact_mode, sc, paused, userdata);
|
||||
}
|
||||
|
|
|
@ -223,8 +223,8 @@ namespace detail
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!m_torrents.empty());
|
||||
assert(m_torrents.front() == t);
|
||||
TORRENT_ASSERT(!m_torrents.empty());
|
||||
TORRENT_ASSERT(m_torrents.front() == t);
|
||||
|
||||
t->torrent_ptr->files_checked(t->unfinished_pieces);
|
||||
m_torrents.pop_front();
|
||||
|
@ -275,7 +275,7 @@ namespace detail
|
|||
|
||||
// move the torrent from
|
||||
// m_torrents to m_processing
|
||||
assert(m_torrents.front() == t);
|
||||
TORRENT_ASSERT(m_torrents.front() == t);
|
||||
|
||||
m_torrents.pop_front();
|
||||
m_processing.push_back(t);
|
||||
|
@ -303,7 +303,7 @@ namespace detail
|
|||
}
|
||||
t->torrent_ptr->abort();
|
||||
|
||||
assert(!m_torrents.empty());
|
||||
TORRENT_ASSERT(!m_torrents.empty());
|
||||
m_torrents.pop_front();
|
||||
}
|
||||
catch(...)
|
||||
|
@ -312,16 +312,16 @@ namespace detail
|
|||
std::cerr << "error while checking resume data\n";
|
||||
#endif
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
assert(!m_torrents.empty());
|
||||
TORRENT_ASSERT(!m_torrents.empty());
|
||||
m_torrents.pop_front();
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
||||
if (!processing) continue;
|
||||
|
||||
try
|
||||
{
|
||||
assert(processing);
|
||||
TORRENT_ASSERT(processing);
|
||||
|
||||
float finished = false;
|
||||
float progress = 0.f;
|
||||
|
@ -335,8 +335,8 @@ namespace detail
|
|||
processing->progress = progress;
|
||||
if (processing->abort)
|
||||
{
|
||||
assert(!m_processing.empty());
|
||||
assert(m_processing.front() == processing);
|
||||
TORRENT_ASSERT(!m_processing.empty());
|
||||
TORRENT_ASSERT(m_processing.front() == processing);
|
||||
|
||||
processing->torrent_ptr->abort();
|
||||
|
||||
|
@ -358,8 +358,8 @@ namespace detail
|
|||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!m_processing.empty());
|
||||
assert(m_processing.front() == processing);
|
||||
TORRENT_ASSERT(!m_processing.empty());
|
||||
TORRENT_ASSERT(m_processing.front() == processing);
|
||||
|
||||
// TODO: factor out the adding of torrents to the session
|
||||
// and to the checker thread to avoid duplicating the
|
||||
|
@ -426,7 +426,7 @@ namespace detail
|
|||
processing->torrent_ptr->get_handle()
|
||||
, e.what()));
|
||||
}
|
||||
assert(!m_processing.empty());
|
||||
TORRENT_ASSERT(!m_processing.empty());
|
||||
|
||||
processing->torrent_ptr->abort();
|
||||
|
||||
|
@ -444,7 +444,7 @@ namespace detail
|
|||
std::cerr << "error while checking files\n";
|
||||
#endif
|
||||
mutex::scoped_lock l(m_mutex);
|
||||
assert(!m_processing.empty());
|
||||
TORRENT_ASSERT(!m_processing.empty());
|
||||
|
||||
processing.reset();
|
||||
m_processing.pop_front();
|
||||
|
@ -454,7 +454,7 @@ namespace detail
|
|||
processing->processing = true;
|
||||
}
|
||||
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ namespace detail
|
|||
{
|
||||
if ((*i)->info_hash == info_hash)
|
||||
{
|
||||
assert((*i)->processing == false);
|
||||
TORRENT_ASSERT((*i)->processing == false);
|
||||
m_torrents.erase(i);
|
||||
return;
|
||||
}
|
||||
|
@ -494,13 +494,13 @@ namespace detail
|
|||
{
|
||||
if ((*i)->info_hash == info_hash)
|
||||
{
|
||||
assert((*i)->processing == false);
|
||||
TORRENT_ASSERT((*i)->processing == false);
|
||||
m_processing.erase(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -509,14 +509,14 @@ namespace detail
|
|||
for (std::deque<boost::shared_ptr<piece_checker_data> >::const_iterator i
|
||||
= m_torrents.begin(); i != m_torrents.end(); ++i)
|
||||
{
|
||||
assert(*i);
|
||||
assert((*i)->torrent_ptr);
|
||||
TORRENT_ASSERT(*i);
|
||||
TORRENT_ASSERT((*i)->torrent_ptr);
|
||||
}
|
||||
for (std::deque<boost::shared_ptr<piece_checker_data> >::const_iterator i
|
||||
= m_processing.begin(); i != m_processing.end(); ++i)
|
||||
{
|
||||
assert(*i);
|
||||
assert((*i)->torrent_ptr);
|
||||
TORRENT_ASSERT(*i);
|
||||
TORRENT_ASSERT((*i)->torrent_ptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -593,7 +593,7 @@ namespace detail
|
|||
|
||||
m_key = rand() + (rand() << 15) + (rand() << 30);
|
||||
std::string print = cl_fprint.to_string();
|
||||
assert(print.length() <= 20);
|
||||
TORRENT_ASSERT(print.length() <= 20);
|
||||
|
||||
// the client's fingerprint
|
||||
std::copy(
|
||||
|
@ -638,7 +638,7 @@ namespace detail
|
|||
void session_impl::abort()
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
assert(!m_abort);
|
||||
TORRENT_ASSERT(!m_abort);
|
||||
// abort the main thread
|
||||
m_abort = true;
|
||||
m_io_service.stop();
|
||||
|
@ -676,11 +676,11 @@ namespace detail
|
|||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(s.connection_speed > 0);
|
||||
assert(s.file_pool_size > 0);
|
||||
TORRENT_ASSERT(s.connection_speed > 0);
|
||||
TORRENT_ASSERT(s.file_pool_size > 0);
|
||||
|
||||
// less than 5 seconds unchoke interval is insane
|
||||
assert(s.unchoke_interval >= 5);
|
||||
TORRENT_ASSERT(s.unchoke_interval >= 5);
|
||||
m_settings = s;
|
||||
m_files.resize(m_settings.file_pool_size);
|
||||
// replace all occurances of '\n' with ' '.
|
||||
|
@ -706,7 +706,7 @@ namespace detail
|
|||
while (ec && retries > 0)
|
||||
{
|
||||
ec = asio::error_code();
|
||||
assert(!ec);
|
||||
TORRENT_ASSERT(!ec);
|
||||
--retries;
|
||||
ep.port(ep.port() + 1);
|
||||
s.sock->bind(ep, ec);
|
||||
|
@ -992,7 +992,7 @@ namespace detail
|
|||
#ifndef NDEBUG
|
||||
catch (...)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ namespace detail
|
|||
// too expensive
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(p->is_disconnecting());
|
||||
TORRENT_ASSERT(p->is_disconnecting());
|
||||
connection_map::iterator i = m_connections.find(p->get_socket());
|
||||
if (i != m_connections.end())
|
||||
{
|
||||
|
@ -1124,7 +1124,7 @@ namespace detail
|
|||
++i;
|
||||
if (i == m_torrents.end())
|
||||
{
|
||||
assert(m_next_connect_torrent == num_torrents);
|
||||
TORRENT_ASSERT(m_next_connect_torrent == num_torrents);
|
||||
i = m_torrents.begin();
|
||||
m_next_connect_torrent = 0;
|
||||
}
|
||||
|
@ -1183,7 +1183,7 @@ namespace detail
|
|||
i != m_torrents.end();)
|
||||
{
|
||||
torrent& t = *i->second;
|
||||
assert(!t.is_aborted());
|
||||
TORRENT_ASSERT(!t.is_aborted());
|
||||
if (t.should_request())
|
||||
{
|
||||
tracker_request req = t.generate_tracker_request();
|
||||
|
@ -1269,9 +1269,9 @@ namespace detail
|
|||
, end(peers.end()); i != end; ++i)
|
||||
{
|
||||
peer_connection* p = *i;
|
||||
assert(p);
|
||||
TORRENT_ASSERT(p);
|
||||
torrent* t = p->associated_torrent().lock().get();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
if (unchoke_set_size > 0)
|
||||
{
|
||||
if (p->is_choked())
|
||||
|
@ -1283,7 +1283,7 @@ namespace detail
|
|||
--unchoke_set_size;
|
||||
++m_num_unchoked;
|
||||
|
||||
assert(p->peer_info_struct());
|
||||
TORRENT_ASSERT(p->peer_info_struct());
|
||||
if (p->peer_info_struct()->optimistically_unchoked)
|
||||
{
|
||||
// force a new optimistic unchoke
|
||||
|
@ -1293,7 +1293,7 @@ namespace detail
|
|||
}
|
||||
else
|
||||
{
|
||||
assert(p->peer_info_struct());
|
||||
TORRENT_ASSERT(p->peer_info_struct());
|
||||
if (!p->is_choked() && !p->peer_info_struct()->optimistically_unchoked)
|
||||
t->choke_peer(*p);
|
||||
if (!p->is_choked())
|
||||
|
@ -1317,7 +1317,7 @@ namespace detail
|
|||
, end(m_connections.end()); i != end; ++i)
|
||||
{
|
||||
peer_connection* p = i->second.get();
|
||||
assert(p);
|
||||
TORRENT_ASSERT(p);
|
||||
policy::peer* pi = p->peer_info_struct();
|
||||
if (!pi) continue;
|
||||
torrent* t = p->associated_torrent().lock().get();
|
||||
|
@ -1325,8 +1325,8 @@ namespace detail
|
|||
|
||||
if (pi->optimistically_unchoked)
|
||||
{
|
||||
assert(!p->is_choked());
|
||||
assert(current_optimistic_unchoke == m_connections.end());
|
||||
TORRENT_ASSERT(!p->is_choked());
|
||||
TORRENT_ASSERT(current_optimistic_unchoke == m_connections.end());
|
||||
current_optimistic_unchoke = i;
|
||||
}
|
||||
|
||||
|
@ -1348,7 +1348,7 @@ namespace detail
|
|||
if (current_optimistic_unchoke != m_connections.end())
|
||||
{
|
||||
torrent* t = current_optimistic_unchoke->second->associated_torrent().lock().get();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
current_optimistic_unchoke->second->peer_info_struct()->optimistically_unchoked = false;
|
||||
t->choke_peer(*current_optimistic_unchoke->second);
|
||||
}
|
||||
|
@ -1358,9 +1358,9 @@ namespace detail
|
|||
}
|
||||
|
||||
torrent* t = optimistic_unchoke_candidate->second->associated_torrent().lock().get();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
bool ret = t->unchoke_peer(*optimistic_unchoke_candidate->second);
|
||||
assert(ret);
|
||||
TORRENT_ASSERT(ret);
|
||||
optimistic_unchoke_candidate->second->peer_info_struct()->optimistically_unchoked = true;
|
||||
}
|
||||
}
|
||||
|
@ -1382,7 +1382,7 @@ namespace detail
|
|||
, bind(&torrent::num_peers, bind(&torrent_map::value_type::second, _1))
|
||||
< bind(&torrent::num_peers, bind(&torrent_map::value_type::second, _2)));
|
||||
|
||||
assert(i != m_torrents.end());
|
||||
TORRENT_ASSERT(i != m_torrents.end());
|
||||
i->second->get_policy().disconnect_one_peer();
|
||||
}
|
||||
}
|
||||
|
@ -1391,7 +1391,7 @@ namespace detail
|
|||
{
|
||||
#ifndef NDEBUG
|
||||
std::cerr << exc.what() << std::endl;
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
#endif
|
||||
}; // msvc 7.1 seems to require this
|
||||
|
||||
|
@ -1411,7 +1411,7 @@ namespace detail
|
|||
try
|
||||
{
|
||||
m_io_service.run();
|
||||
assert(m_abort == true);
|
||||
TORRENT_ASSERT(m_abort == true);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
@ -1419,7 +1419,7 @@ namespace detail
|
|||
std::cerr << e.what() << "\n";
|
||||
std::string err = e.what();
|
||||
#endif
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
while (!m_abort);
|
||||
|
@ -1455,7 +1455,7 @@ namespace detail
|
|||
&& !i->second->trackers().empty())
|
||||
{
|
||||
tracker_request req = i->second->generate_tracker_request();
|
||||
assert(!m_listen_sockets.empty());
|
||||
TORRENT_ASSERT(!m_listen_sockets.empty());
|
||||
req.listen_port = 0;
|
||||
if (!m_listen_sockets.empty())
|
||||
req.listen_port = m_listen_sockets.front().external_port;
|
||||
|
@ -1501,7 +1501,7 @@ namespace detail
|
|||
#endif
|
||||
|
||||
l.lock();
|
||||
assert(m_abort);
|
||||
TORRENT_ASSERT(m_abort);
|
||||
m_abort = true;
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
|
@ -1514,7 +1514,7 @@ namespace detail
|
|||
for (torrent_map::iterator i = m_torrents.begin();
|
||||
i != m_torrents.end(); ++i)
|
||||
{
|
||||
assert(i->second->num_peers() == 0);
|
||||
TORRENT_ASSERT(i->second->num_peers() == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1523,8 +1523,8 @@ namespace detail
|
|||
#endif
|
||||
m_torrents.clear();
|
||||
|
||||
assert(m_torrents.empty());
|
||||
assert(m_connections.empty());
|
||||
TORRENT_ASSERT(m_torrents.empty());
|
||||
TORRENT_ASSERT(m_connections.empty());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1539,7 +1539,7 @@ namespace detail
|
|||
= m_torrents.begin(); j != m_torrents.end(); ++j)
|
||||
{
|
||||
torrent* p = boost::get_pointer(j->second);
|
||||
assert(p);
|
||||
TORRENT_ASSERT(p);
|
||||
}
|
||||
#endif
|
||||
if (i != m_torrents.end()) return i->second;
|
||||
|
@ -1603,7 +1603,7 @@ namespace detail
|
|||
, bool paused
|
||||
, void* userdata)
|
||||
{
|
||||
assert(!save_path.empty());
|
||||
TORRENT_ASSERT(!save_path.empty());
|
||||
|
||||
if (ti->begin_files() == ti->end_files())
|
||||
throw std::runtime_error("no files in torrent");
|
||||
|
@ -1683,7 +1683,7 @@ namespace detail
|
|||
{
|
||||
|
||||
// TODO: support resume data in this case
|
||||
assert(!save_path.empty());
|
||||
TORRENT_ASSERT(!save_path.empty());
|
||||
{
|
||||
// lock the checker_thread
|
||||
mutex::scoped_lock l(m_checker_impl.m_mutex);
|
||||
|
@ -1703,7 +1703,7 @@ namespace detail
|
|||
throw duplicate_torrent();
|
||||
|
||||
// you cannot add new torrents to a session that is closing down
|
||||
assert(!is_aborted());
|
||||
TORRENT_ASSERT(!is_aborted());
|
||||
|
||||
// create the torrent and the data associated with
|
||||
// the checker thread and store it before starting
|
||||
|
@ -1732,8 +1732,8 @@ namespace detail
|
|||
void session_impl::remove_torrent(const torrent_handle& h)
|
||||
{
|
||||
if (h.m_ses != this) return;
|
||||
assert(h.m_chk == &m_checker_impl || h.m_chk == 0);
|
||||
assert(h.m_ses != 0);
|
||||
TORRENT_ASSERT(h.m_chk == &m_checker_impl || h.m_chk == 0);
|
||||
TORRENT_ASSERT(h.m_ses != 0);
|
||||
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
|
@ -1750,8 +1750,8 @@ namespace detail
|
|||
&& !t.torrent_file().trackers().empty())
|
||||
{
|
||||
tracker_request req = t.generate_tracker_request();
|
||||
assert(req.event == tracker_request::stopped);
|
||||
assert(!m_listen_sockets.empty());
|
||||
TORRENT_ASSERT(req.event == tracker_request::stopped);
|
||||
TORRENT_ASSERT(!m_listen_sockets.empty());
|
||||
req.listen_port = 0;
|
||||
if (!m_listen_sockets.empty())
|
||||
req.listen_port = m_listen_sockets.front().external_port;
|
||||
|
@ -1778,7 +1778,7 @@ namespace detail
|
|||
sha1_hash i_hash = t.torrent_file().info_hash();
|
||||
#endif
|
||||
m_torrents.erase(i);
|
||||
assert(m_torrents.find(i_hash) == m_torrents.end());
|
||||
TORRENT_ASSERT(m_torrents.find(i_hash) == m_torrents.end());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1985,7 +1985,7 @@ namespace detail
|
|||
// basically, make sure you call listen_on() before
|
||||
// start_dht(). See documentation for listen_on() for
|
||||
// more information.
|
||||
assert(m_listen_interface.port() > 0);
|
||||
TORRENT_ASSERT(m_listen_interface.port() > 0);
|
||||
m_dht_settings.service_port = m_listen_interface.port();
|
||||
}
|
||||
m_external_udp_port = m_dht_settings.service_port;
|
||||
|
@ -2035,21 +2035,21 @@ namespace detail
|
|||
|
||||
entry session_impl::dht_state() const
|
||||
{
|
||||
assert(m_dht);
|
||||
TORRENT_ASSERT(m_dht);
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
return m_dht->state();
|
||||
}
|
||||
|
||||
void session_impl::add_dht_node(std::pair<std::string, int> const& node)
|
||||
{
|
||||
assert(m_dht);
|
||||
TORRENT_ASSERT(m_dht);
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
m_dht->add_node(node);
|
||||
}
|
||||
|
||||
void session_impl::add_dht_router(std::pair<std::string, int> const& node)
|
||||
{
|
||||
assert(m_dht);
|
||||
TORRENT_ASSERT(m_dht);
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
m_dht->add_router_node(node);
|
||||
}
|
||||
|
@ -2090,7 +2090,7 @@ namespace detail
|
|||
#endif
|
||||
m_thread->join();
|
||||
|
||||
assert(m_torrents.empty());
|
||||
TORRENT_ASSERT(m_torrents.empty());
|
||||
|
||||
// it's important that the main thread is closed completely before
|
||||
// the checker thread is terminated. Because all the connections
|
||||
|
@ -2117,8 +2117,8 @@ namespace detail
|
|||
#endif
|
||||
m_checker_thread->join();
|
||||
|
||||
assert(m_torrents.empty());
|
||||
assert(m_connections.empty());
|
||||
TORRENT_ASSERT(m_torrents.empty());
|
||||
TORRENT_ASSERT(m_connections.empty());
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " shutdown complete!\n";
|
||||
#endif
|
||||
|
@ -2126,7 +2126,7 @@ namespace detail
|
|||
|
||||
void session_impl::set_max_uploads(int limit)
|
||||
{
|
||||
assert(limit > 0 || limit == -1);
|
||||
TORRENT_ASSERT(limit > 0 || limit == -1);
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
@ -2137,7 +2137,7 @@ namespace detail
|
|||
|
||||
void session_impl::set_max_connections(int limit)
|
||||
{
|
||||
assert(limit > 0 || limit == -1);
|
||||
TORRENT_ASSERT(limit > 0 || limit == -1);
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
@ -2148,7 +2148,7 @@ namespace detail
|
|||
|
||||
void session_impl::set_max_half_open_connections(int limit)
|
||||
{
|
||||
assert(limit > 0 || limit == -1);
|
||||
TORRENT_ASSERT(limit > 0 || limit == -1);
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
@ -2159,7 +2159,7 @@ namespace detail
|
|||
|
||||
void session_impl::set_download_rate_limit(int bytes_per_second)
|
||||
{
|
||||
assert(bytes_per_second > 0 || bytes_per_second == -1);
|
||||
TORRENT_ASSERT(bytes_per_second > 0 || bytes_per_second == -1);
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
@ -2170,7 +2170,7 @@ namespace detail
|
|||
|
||||
void session_impl::set_upload_rate_limit(int bytes_per_second)
|
||||
{
|
||||
assert(bytes_per_second > 0 || bytes_per_second == -1);
|
||||
TORRENT_ASSERT(bytes_per_second > 0 || bytes_per_second == -1);
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
@ -2303,11 +2303,11 @@ namespace detail
|
|||
|
||||
void session_impl::free_buffer(char* buf, int size)
|
||||
{
|
||||
assert(size % send_buffer_size == 0);
|
||||
TORRENT_ASSERT(size % send_buffer_size == 0);
|
||||
int num_buffers = size / send_buffer_size;
|
||||
#ifdef TORRENT_STATS
|
||||
m_buffer_allocations -= num_buffers;
|
||||
assert(m_buffer_allocations >= 0);
|
||||
TORRENT_ASSERT(m_buffer_allocations >= 0);
|
||||
m_buffer_usage_logger << log_time() << " protocol_buffer: "
|
||||
<< (m_buffer_allocations * send_buffer_size) << std::endl;
|
||||
#endif
|
||||
|
@ -2317,14 +2317,14 @@ namespace detail
|
|||
#ifndef NDEBUG
|
||||
void session_impl::check_invariant() const
|
||||
{
|
||||
assert(m_max_connections > 0);
|
||||
assert(m_max_uploads > 0);
|
||||
TORRENT_ASSERT(m_max_connections > 0);
|
||||
TORRENT_ASSERT(m_max_uploads > 0);
|
||||
int unchokes = 0;
|
||||
int num_optimistic = 0;
|
||||
for (connection_map::const_iterator i = m_connections.begin();
|
||||
i != m_connections.end(); ++i)
|
||||
{
|
||||
assert(i->second);
|
||||
TORRENT_ASSERT(i->second);
|
||||
boost::shared_ptr<torrent> t = i->second->associated_torrent().lock();
|
||||
|
||||
if (!i->second->is_choked()) ++unchokes;
|
||||
|
@ -2332,17 +2332,17 @@ namespace detail
|
|||
&& i->second->peer_info_struct()->optimistically_unchoked)
|
||||
{
|
||||
++num_optimistic;
|
||||
assert(!i->second->is_choked());
|
||||
TORRENT_ASSERT(!i->second->is_choked());
|
||||
}
|
||||
if (t && i->second->peer_info_struct())
|
||||
{
|
||||
assert(t->get_policy().has_connection(boost::get_pointer(i->second)));
|
||||
TORRENT_ASSERT(t->get_policy().has_connection(boost::get_pointer(i->second)));
|
||||
}
|
||||
}
|
||||
assert(num_optimistic == 0 || num_optimistic == 1);
|
||||
TORRENT_ASSERT(num_optimistic == 0 || num_optimistic == 1);
|
||||
if (m_num_unchoked != unchokes)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -2508,7 +2508,7 @@ namespace detail
|
|||
return;
|
||||
}
|
||||
|
||||
assert(*slot_iter == p.index);
|
||||
TORRENT_ASSERT(*slot_iter == p.index);
|
||||
int slot_index = static_cast<int>(slot_iter - tmp_pieces.begin());
|
||||
unsigned long adler
|
||||
= torrent_ptr->filesystem().piece_crc(
|
||||
|
|
|
@ -211,7 +211,7 @@ namespace libtorrent
|
|||
write_uint8(m_remote_endpoint.address().is_v4()?1:4, p); // address type
|
||||
write_address(m_remote_endpoint.address(), p);
|
||||
write_uint16(m_remote_endpoint.port(), p);
|
||||
assert(p - &m_buffer[0] == int(m_buffer.size()));
|
||||
TORRENT_ASSERT(p - &m_buffer[0] == int(m_buffer.size()));
|
||||
|
||||
asio::async_write(m_sock, asio::buffer(m_buffer)
|
||||
, boost::bind(&socks5_stream::connect1, this, _1, h));
|
||||
|
|
|
@ -355,9 +355,9 @@ namespace libtorrent
|
|||
: m_info(info)
|
||||
, m_files(fp)
|
||||
{
|
||||
assert(info->begin_files(true) != info->end_files(true));
|
||||
TORRENT_ASSERT(info->begin_files(true) != info->end_files(true));
|
||||
m_save_path = fs::complete(path);
|
||||
assert(m_save_path.is_complete());
|
||||
TORRENT_ASSERT(m_save_path.is_complete());
|
||||
}
|
||||
|
||||
void release_files();
|
||||
|
@ -400,7 +400,7 @@ namespace libtorrent
|
|||
partial.update(&m_scratch_buffer[0], ph.offset);
|
||||
whole.update(&m_scratch_buffer[0], slot_size1);
|
||||
hasher partial_copy = ph.h;
|
||||
assert(ph.offset == 0 || partial_copy.final() == partial.final());
|
||||
TORRENT_ASSERT(ph.offset == 0 || partial_copy.final() == partial.final());
|
||||
#endif
|
||||
int slot_size = piece_size - ph.offset;
|
||||
if (slot_size > 0)
|
||||
|
@ -411,7 +411,7 @@ namespace libtorrent
|
|||
}
|
||||
#ifndef NDEBUG
|
||||
sha1_hash ret = ph.h.final();
|
||||
assert(ret == whole.final());
|
||||
TORRENT_ASSERT(ret == whole.final());
|
||||
return ret;
|
||||
#else
|
||||
return ph.h.final();
|
||||
|
@ -690,20 +690,20 @@ namespace libtorrent
|
|||
, int size
|
||||
, bool fill_zero)
|
||||
{
|
||||
assert(buf != 0);
|
||||
assert(slot >= 0 && slot < m_info->num_pieces());
|
||||
assert(offset >= 0);
|
||||
assert(offset < m_info->piece_size(slot));
|
||||
assert(size > 0);
|
||||
TORRENT_ASSERT(buf != 0);
|
||||
TORRENT_ASSERT(slot >= 0 && slot < m_info->num_pieces());
|
||||
TORRENT_ASSERT(offset >= 0);
|
||||
TORRENT_ASSERT(offset < m_info->piece_size(slot));
|
||||
TORRENT_ASSERT(size > 0);
|
||||
|
||||
#ifndef NDEBUG
|
||||
std::vector<file_slice> slices
|
||||
= m_info->map_block(slot, offset, size, true);
|
||||
assert(!slices.empty());
|
||||
TORRENT_ASSERT(!slices.empty());
|
||||
#endif
|
||||
|
||||
size_type start = slot * (size_type)m_info->piece_length() + offset;
|
||||
assert(start + size <= m_info->total_size());
|
||||
TORRENT_ASSERT(start + size <= m_info->total_size());
|
||||
|
||||
// find the file iterator and file offset
|
||||
size_type file_offset = start;
|
||||
|
@ -722,9 +722,9 @@ namespace libtorrent
|
|||
boost::shared_ptr<file> in(m_files.open_file(
|
||||
this, m_save_path / file_iter->path, file::in));
|
||||
|
||||
assert(file_offset < file_iter->size);
|
||||
TORRENT_ASSERT(file_offset < file_iter->size);
|
||||
|
||||
assert(slices[0].offset == file_offset);
|
||||
TORRENT_ASSERT(slices[0].offset == file_offset);
|
||||
|
||||
size_type new_pos = in->seek(file_offset);
|
||||
if (new_pos != file_offset)
|
||||
|
@ -738,7 +738,7 @@ namespace libtorrent
|
|||
|
||||
#ifndef NDEBUG
|
||||
size_type in_tell = in->tell();
|
||||
assert(in_tell == file_offset);
|
||||
TORRENT_ASSERT(in_tell == file_offset);
|
||||
#endif
|
||||
|
||||
int left_to_read = size;
|
||||
|
@ -747,7 +747,7 @@ namespace libtorrent
|
|||
if (offset + left_to_read > slot_size)
|
||||
left_to_read = slot_size - offset;
|
||||
|
||||
assert(left_to_read >= 0);
|
||||
TORRENT_ASSERT(left_to_read >= 0);
|
||||
|
||||
size_type result = left_to_read;
|
||||
|
||||
|
@ -764,10 +764,10 @@ namespace libtorrent
|
|||
if (read_bytes > 0)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
assert(int(slices.size()) > counter);
|
||||
TORRENT_ASSERT(int(slices.size()) > counter);
|
||||
size_type slice_size = slices[counter].size;
|
||||
assert(slice_size == read_bytes);
|
||||
assert(m_info->file_at(slices[counter].file_index, true).path
|
||||
TORRENT_ASSERT(slice_size == read_bytes);
|
||||
TORRENT_ASSERT(m_info->file_at(slices[counter].file_index, true).path
|
||||
== file_iter->path);
|
||||
#endif
|
||||
|
||||
|
@ -785,7 +785,7 @@ namespace libtorrent
|
|||
|
||||
left_to_read -= read_bytes;
|
||||
buf_pos += read_bytes;
|
||||
assert(buf_pos >= 0);
|
||||
TORRENT_ASSERT(buf_pos >= 0);
|
||||
file_offset += read_bytes;
|
||||
}
|
||||
|
||||
|
@ -815,16 +815,16 @@ namespace libtorrent
|
|||
, int offset
|
||||
, int size)
|
||||
{
|
||||
assert(buf != 0);
|
||||
assert(slot >= 0);
|
||||
assert(slot < m_info->num_pieces());
|
||||
assert(offset >= 0);
|
||||
assert(size > 0);
|
||||
TORRENT_ASSERT(buf != 0);
|
||||
TORRENT_ASSERT(slot >= 0);
|
||||
TORRENT_ASSERT(slot < m_info->num_pieces());
|
||||
TORRENT_ASSERT(offset >= 0);
|
||||
TORRENT_ASSERT(size > 0);
|
||||
|
||||
#ifndef NDEBUG
|
||||
std::vector<file_slice> slices
|
||||
= m_info->map_block(slot, offset, size, true);
|
||||
assert(!slices.empty());
|
||||
TORRENT_ASSERT(!slices.empty());
|
||||
#endif
|
||||
|
||||
size_type start = slot * (size_type)m_info->piece_length() + offset;
|
||||
|
@ -840,15 +840,15 @@ namespace libtorrent
|
|||
|
||||
file_offset -= file_iter->size;
|
||||
++file_iter;
|
||||
assert(file_iter != m_info->end_files(true));
|
||||
TORRENT_ASSERT(file_iter != m_info->end_files(true));
|
||||
}
|
||||
|
||||
fs::path p(m_save_path / file_iter->path);
|
||||
boost::shared_ptr<file> out = m_files.open_file(
|
||||
this, p, file::out | file::in);
|
||||
|
||||
assert(file_offset < file_iter->size);
|
||||
assert(slices[0].offset == file_offset);
|
||||
TORRENT_ASSERT(file_offset < file_iter->size);
|
||||
TORRENT_ASSERT(slices[0].offset == file_offset);
|
||||
|
||||
size_type pos = out->seek(file_offset);
|
||||
|
||||
|
@ -865,7 +865,7 @@ namespace libtorrent
|
|||
if (offset + left_to_write > slot_size)
|
||||
left_to_write = slot_size - offset;
|
||||
|
||||
assert(left_to_write >= 0);
|
||||
TORRENT_ASSERT(left_to_write >= 0);
|
||||
|
||||
int buf_pos = 0;
|
||||
#ifndef NDEBUG
|
||||
|
@ -876,19 +876,19 @@ namespace libtorrent
|
|||
int write_bytes = left_to_write;
|
||||
if (file_offset + write_bytes > file_iter->size)
|
||||
{
|
||||
assert(file_iter->size >= file_offset);
|
||||
TORRENT_ASSERT(file_iter->size >= file_offset);
|
||||
write_bytes = static_cast<int>(file_iter->size - file_offset);
|
||||
}
|
||||
|
||||
if (write_bytes > 0)
|
||||
{
|
||||
assert(int(slices.size()) > counter);
|
||||
assert(slices[counter].size == write_bytes);
|
||||
assert(m_info->file_at(slices[counter].file_index, true).path
|
||||
TORRENT_ASSERT(int(slices.size()) > counter);
|
||||
TORRENT_ASSERT(slices[counter].size == write_bytes);
|
||||
TORRENT_ASSERT(m_info->file_at(slices[counter].file_index, true).path
|
||||
== file_iter->path);
|
||||
|
||||
assert(buf_pos >= 0);
|
||||
assert(write_bytes >= 0);
|
||||
TORRENT_ASSERT(buf_pos >= 0);
|
||||
TORRENT_ASSERT(write_bytes >= 0);
|
||||
size_type written = out->write(buf + buf_pos, write_bytes);
|
||||
|
||||
if (written != write_bytes)
|
||||
|
@ -900,9 +900,9 @@ namespace libtorrent
|
|||
|
||||
left_to_write -= write_bytes;
|
||||
buf_pos += write_bytes;
|
||||
assert(buf_pos >= 0);
|
||||
TORRENT_ASSERT(buf_pos >= 0);
|
||||
file_offset += write_bytes;
|
||||
assert(file_offset <= file_iter->size);
|
||||
TORRENT_ASSERT(file_offset <= file_iter->size);
|
||||
}
|
||||
|
||||
if (left_to_write > 0)
|
||||
|
@ -912,7 +912,7 @@ namespace libtorrent
|
|||
#endif
|
||||
++file_iter;
|
||||
|
||||
assert(file_iter != m_info->end_files(true));
|
||||
TORRENT_ASSERT(file_iter != m_info->end_files(true));
|
||||
fs::path p = m_save_path / file_iter->path;
|
||||
file_offset = 0;
|
||||
out = m_files.open_file(
|
||||
|
@ -931,7 +931,7 @@ namespace libtorrent
|
|||
|
||||
bool supports_sparse_files(fs::path const& p)
|
||||
{
|
||||
assert(p.is_complete());
|
||||
TORRENT_ASSERT(p.is_complete());
|
||||
#if defined(_WIN32)
|
||||
// assume windows API is available
|
||||
DWORD max_component_len = 0;
|
||||
|
@ -1105,7 +1105,7 @@ namespace libtorrent
|
|||
j.priority = priority;
|
||||
// if a buffer is not specified, only one block can be read
|
||||
// since that is the size of the pool allocator's buffers
|
||||
assert(r.length <= 16 * 1024 || buffer != 0);
|
||||
TORRENT_ASSERT(r.length <= 16 * 1024 || buffer != 0);
|
||||
m_io_thread.add_job(j, handler);
|
||||
}
|
||||
|
||||
|
@ -1114,7 +1114,7 @@ namespace libtorrent
|
|||
, char const* buffer
|
||||
, boost::function<void(int, disk_io_job const&)> const& handler)
|
||||
{
|
||||
assert(r.length <= 16 * 1024);
|
||||
TORRENT_ASSERT(r.length <= 16 * 1024);
|
||||
|
||||
disk_io_job j;
|
||||
j.storage = this;
|
||||
|
@ -1157,7 +1157,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
int slot = m_piece_to_slot[piece];
|
||||
assert(slot != has_no_slot);
|
||||
TORRENT_ASSERT(slot != has_no_slot);
|
||||
return m_storage->hash_for_slot(slot, ph, m_info->piece_size(piece));
|
||||
}
|
||||
|
||||
|
@ -1204,12 +1204,12 @@ namespace libtorrent
|
|||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(piece_index >= 0 && piece_index < (int)m_piece_to_slot.size());
|
||||
assert(m_piece_to_slot[piece_index] >= 0);
|
||||
TORRENT_ASSERT(piece_index >= 0 && piece_index < (int)m_piece_to_slot.size());
|
||||
TORRENT_ASSERT(m_piece_to_slot[piece_index] >= 0);
|
||||
|
||||
int slot_index = m_piece_to_slot[piece_index];
|
||||
|
||||
assert(slot_index >= 0);
|
||||
TORRENT_ASSERT(slot_index >= 0);
|
||||
|
||||
m_slot_to_piece[slot_index] = unassigned;
|
||||
m_piece_to_slot[piece_index] = has_no_slot;
|
||||
|
@ -1218,7 +1218,7 @@ namespace libtorrent
|
|||
|
||||
int piece_manager::slot_for_piece(int piece_index) const
|
||||
{
|
||||
assert(piece_index >= 0 && piece_index < m_info->num_pieces());
|
||||
TORRENT_ASSERT(piece_index >= 0 && piece_index < m_info->num_pieces());
|
||||
return m_piece_to_slot[piece_index];
|
||||
}
|
||||
|
||||
|
@ -1228,9 +1228,9 @@ namespace libtorrent
|
|||
, piece_picker::block_info const* bi)
|
||||
try
|
||||
{
|
||||
assert(slot_index >= 0);
|
||||
assert(slot_index < m_info->num_pieces());
|
||||
assert(block_size > 0);
|
||||
TORRENT_ASSERT(slot_index >= 0);
|
||||
TORRENT_ASSERT(slot_index < m_info->num_pieces());
|
||||
TORRENT_ASSERT(block_size > 0);
|
||||
|
||||
adler32_crc crc;
|
||||
std::vector<char> buf(block_size);
|
||||
|
@ -1270,14 +1270,14 @@ namespace libtorrent
|
|||
, int offset
|
||||
, int size)
|
||||
{
|
||||
assert(buf);
|
||||
assert(offset >= 0);
|
||||
assert(size > 0);
|
||||
assert(piece_index >= 0 && piece_index < (int)m_piece_to_slot.size());
|
||||
assert(m_piece_to_slot[piece_index] >= 0
|
||||
TORRENT_ASSERT(buf);
|
||||
TORRENT_ASSERT(offset >= 0);
|
||||
TORRENT_ASSERT(size > 0);
|
||||
TORRENT_ASSERT(piece_index >= 0 && piece_index < (int)m_piece_to_slot.size());
|
||||
TORRENT_ASSERT(m_piece_to_slot[piece_index] >= 0
|
||||
&& m_piece_to_slot[piece_index] < (int)m_slot_to_piece.size());
|
||||
int slot = m_piece_to_slot[piece_index];
|
||||
assert(slot >= 0 && slot < (int)m_slot_to_piece.size());
|
||||
TORRENT_ASSERT(slot >= 0 && slot < (int)m_slot_to_piece.size());
|
||||
return m_storage->read(buf, slot, offset, size);
|
||||
}
|
||||
|
||||
|
@ -1287,15 +1287,15 @@ namespace libtorrent
|
|||
, int offset
|
||||
, int size)
|
||||
{
|
||||
assert(buf);
|
||||
assert(offset >= 0);
|
||||
assert(size > 0);
|
||||
assert(piece_index >= 0 && piece_index < (int)m_piece_to_slot.size());
|
||||
TORRENT_ASSERT(buf);
|
||||
TORRENT_ASSERT(offset >= 0);
|
||||
TORRENT_ASSERT(size > 0);
|
||||
TORRENT_ASSERT(piece_index >= 0 && piece_index < (int)m_piece_to_slot.size());
|
||||
|
||||
if (offset == 0)
|
||||
{
|
||||
partial_hash& ph = m_piece_hasher[piece_index];
|
||||
assert(ph.offset == 0);
|
||||
TORRENT_ASSERT(ph.offset == 0);
|
||||
ph.offset = size;
|
||||
ph.h.update(buf, size);
|
||||
}
|
||||
|
@ -1304,8 +1304,8 @@ namespace libtorrent
|
|||
std::map<int, partial_hash>::iterator i = m_piece_hasher.find(piece_index);
|
||||
if (i != m_piece_hasher.end())
|
||||
{
|
||||
assert(i->second.offset > 0);
|
||||
assert(offset >= i->second.offset);
|
||||
TORRENT_ASSERT(i->second.offset > 0);
|
||||
TORRENT_ASSERT(offset >= i->second.offset);
|
||||
if (offset == i->second.offset)
|
||||
{
|
||||
i->second.offset += size;
|
||||
|
@ -1315,7 +1315,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
int slot = allocate_slot_for_piece(piece_index);
|
||||
assert(slot >= 0 && slot < (int)m_slot_to_piece.size());
|
||||
TORRENT_ASSERT(slot >= 0 && slot < (int)m_slot_to_piece.size());
|
||||
m_storage->write(buf, slot, offset, size);
|
||||
}
|
||||
|
||||
|
@ -1329,13 +1329,13 @@ namespace libtorrent
|
|||
{
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert((int)have_pieces.size() == m_info->num_pieces());
|
||||
TORRENT_ASSERT((int)have_pieces.size() == m_info->num_pieces());
|
||||
|
||||
const int piece_size = static_cast<int>(m_info->piece_length());
|
||||
const int last_piece_size = static_cast<int>(m_info->piece_size(
|
||||
m_info->num_pieces() - 1));
|
||||
|
||||
assert((int)piece_data.size() >= last_piece_size);
|
||||
TORRENT_ASSERT((int)piece_data.size() >= last_piece_size);
|
||||
|
||||
// calculate a small digest, with the same
|
||||
// size as the last piece. And a large digest
|
||||
|
@ -1343,7 +1343,7 @@ namespace libtorrent
|
|||
hasher small_digest;
|
||||
small_digest.update(&piece_data[0], last_piece_size);
|
||||
hasher large_digest(small_digest);
|
||||
assert(piece_size - last_piece_size >= 0);
|
||||
TORRENT_ASSERT(piece_size - last_piece_size >= 0);
|
||||
if (piece_size - last_piece_size > 0)
|
||||
{
|
||||
large_digest.update(
|
||||
|
@ -1395,7 +1395,7 @@ namespace libtorrent
|
|||
// we have already found a piece with
|
||||
// this index.
|
||||
int other_slot = m_piece_to_slot[piece_index];
|
||||
assert(other_slot >= 0);
|
||||
TORRENT_ASSERT(other_slot >= 0);
|
||||
|
||||
// take one of the other matching pieces
|
||||
// that hasn't already been assigned
|
||||
|
@ -1410,7 +1410,7 @@ namespace libtorrent
|
|||
if (other_piece >= 0)
|
||||
{
|
||||
// replace the old slot with 'other_piece'
|
||||
assert(have_pieces[other_piece] == false);
|
||||
TORRENT_ASSERT(have_pieces[other_piece] == false);
|
||||
have_pieces[other_piece] = true;
|
||||
m_slot_to_piece[other_slot] = other_piece;
|
||||
m_piece_to_slot[other_piece] = other_slot;
|
||||
|
@ -1426,8 +1426,8 @@ namespace libtorrent
|
|||
m_slot_to_piece[other_slot] = unassigned;
|
||||
m_free_slots.push_back(other_slot);
|
||||
}
|
||||
assert(m_piece_to_slot[piece_index] != current_slot);
|
||||
assert(m_piece_to_slot[piece_index] >= 0);
|
||||
TORRENT_ASSERT(m_piece_to_slot[piece_index] != current_slot);
|
||||
TORRENT_ASSERT(m_piece_to_slot[piece_index] >= 0);
|
||||
m_piece_to_slot[piece_index] = has_no_slot;
|
||||
#ifndef NDEBUG
|
||||
// to make the assert happy, a few lines down
|
||||
|
@ -1439,8 +1439,8 @@ namespace libtorrent
|
|||
++num_pieces;
|
||||
}
|
||||
|
||||
assert(have_pieces[piece_index] == false);
|
||||
assert(m_piece_to_slot[piece_index] == has_no_slot);
|
||||
TORRENT_ASSERT(have_pieces[piece_index] == false);
|
||||
TORRENT_ASSERT(m_piece_to_slot[piece_index] == has_no_slot);
|
||||
have_pieces[piece_index] = true;
|
||||
|
||||
return piece_index;
|
||||
|
@ -1462,8 +1462,8 @@ namespace libtorrent
|
|||
// lock because we're writing to have_pieces
|
||||
boost::recursive_mutex::scoped_lock l(mutex);
|
||||
|
||||
assert(have_pieces[free_piece] == false);
|
||||
assert(m_piece_to_slot[free_piece] == has_no_slot);
|
||||
TORRENT_ASSERT(have_pieces[free_piece] == false);
|
||||
TORRENT_ASSERT(m_piece_to_slot[free_piece] == has_no_slot);
|
||||
have_pieces[free_piece] = true;
|
||||
++num_pieces;
|
||||
|
||||
|
@ -1471,7 +1471,7 @@ namespace libtorrent
|
|||
}
|
||||
else
|
||||
{
|
||||
assert(free_piece == unassigned);
|
||||
TORRENT_ASSERT(free_piece == unassigned);
|
||||
return unassigned;
|
||||
}
|
||||
}
|
||||
|
@ -1489,7 +1489,7 @@ namespace libtorrent
|
|||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_info->piece_length() > 0);
|
||||
TORRENT_ASSERT(m_info->piece_length() > 0);
|
||||
|
||||
m_compact_mode = compact_mode;
|
||||
|
||||
|
@ -1539,7 +1539,7 @@ namespace libtorrent
|
|||
}
|
||||
else
|
||||
{
|
||||
assert(data.piece_map[i] == unallocated);
|
||||
TORRENT_ASSERT(data.piece_map[i] == unallocated);
|
||||
m_unallocated_slots.push_back(i);
|
||||
}
|
||||
}
|
||||
|
@ -1600,7 +1600,7 @@ namespace libtorrent
|
|||
std::pair<bool, float> piece_manager::check_files(
|
||||
std::vector<bool>& pieces, int& num_pieces, boost::recursive_mutex& mutex)
|
||||
{
|
||||
assert(num_pieces == std::count(pieces.begin(), pieces.end(), true));
|
||||
TORRENT_ASSERT(num_pieces == std::count(pieces.begin(), pieces.end(), true));
|
||||
|
||||
if (m_state == state_allocating)
|
||||
{
|
||||
|
@ -1622,7 +1622,7 @@ namespace libtorrent
|
|||
// if we're not in compact mode, make sure the
|
||||
// pieces are spread out and placed at their
|
||||
// final position.
|
||||
assert(!m_unallocated_slots.empty());
|
||||
TORRENT_ASSERT(!m_unallocated_slots.empty());
|
||||
|
||||
if (!m_fill_mode)
|
||||
{
|
||||
|
@ -1649,7 +1649,7 @@ namespace libtorrent
|
|||
|
||||
if (!m_unallocated_slots.empty() && !m_compact_mode)
|
||||
{
|
||||
assert(!m_fill_mode);
|
||||
TORRENT_ASSERT(!m_fill_mode);
|
||||
std::vector<int>().swap(m_unallocated_slots);
|
||||
std::fill(m_slot_to_piece.begin(), m_slot_to_piece.end(), int(unassigned));
|
||||
m_free_slots.resize(m_info->num_pieces());
|
||||
|
@ -1661,7 +1661,7 @@ namespace libtorrent
|
|||
return std::make_pair(true, 1.f);
|
||||
}
|
||||
|
||||
assert(m_state == state_full_check);
|
||||
TORRENT_ASSERT(m_state == state_full_check);
|
||||
|
||||
// ------------------------
|
||||
// DO THE FULL CHECK
|
||||
|
@ -1692,8 +1692,8 @@ namespace libtorrent
|
|||
int piece_index = identify_data(m_piece_data, m_current_slot
|
||||
, pieces, num_pieces, m_hash_to_piece, mutex);
|
||||
|
||||
assert(num_pieces == std::count(pieces.begin(), pieces.end(), true));
|
||||
assert(piece_index == unassigned || piece_index >= 0);
|
||||
TORRENT_ASSERT(num_pieces == std::count(pieces.begin(), pieces.end(), true));
|
||||
TORRENT_ASSERT(piece_index == unassigned || piece_index >= 0);
|
||||
|
||||
const bool this_should_move = piece_index >= 0 && m_slot_to_piece[piece_index] != unallocated;
|
||||
const bool other_should_move = m_piece_to_slot[m_current_slot] != has_no_slot;
|
||||
|
@ -1727,10 +1727,10 @@ namespace libtorrent
|
|||
// case 1
|
||||
if (this_should_move && !other_should_move)
|
||||
{
|
||||
assert(piece_index != m_current_slot);
|
||||
TORRENT_ASSERT(piece_index != m_current_slot);
|
||||
|
||||
const int other_slot = piece_index;
|
||||
assert(other_slot >= 0);
|
||||
TORRENT_ASSERT(other_slot >= 0);
|
||||
int other_piece = m_slot_to_piece[other_slot];
|
||||
|
||||
m_slot_to_piece[other_slot] = piece_index;
|
||||
|
@ -1742,7 +1742,7 @@ namespace libtorrent
|
|||
{
|
||||
std::vector<int>::iterator i =
|
||||
std::find(m_free_slots.begin(), m_free_slots.end(), other_slot);
|
||||
assert(i != m_free_slots.end());
|
||||
TORRENT_ASSERT(i != m_free_slots.end());
|
||||
m_free_slots.erase(i);
|
||||
m_free_slots.push_back(m_current_slot);
|
||||
}
|
||||
|
@ -1752,17 +1752,17 @@ namespace libtorrent
|
|||
else
|
||||
m_storage->move_slot(m_current_slot, other_slot);
|
||||
|
||||
assert(m_slot_to_piece[m_current_slot] == unassigned
|
||||
TORRENT_ASSERT(m_slot_to_piece[m_current_slot] == unassigned
|
||||
|| m_piece_to_slot[m_slot_to_piece[m_current_slot]] == m_current_slot);
|
||||
}
|
||||
// case 2
|
||||
else if (!this_should_move && other_should_move)
|
||||
{
|
||||
assert(piece_index != m_current_slot);
|
||||
TORRENT_ASSERT(piece_index != m_current_slot);
|
||||
|
||||
const int other_piece = m_current_slot;
|
||||
const int other_slot = m_piece_to_slot[other_piece];
|
||||
assert(other_slot >= 0);
|
||||
TORRENT_ASSERT(other_slot >= 0);
|
||||
|
||||
m_slot_to_piece[m_current_slot] = other_piece;
|
||||
m_slot_to_piece[other_slot] = piece_index;
|
||||
|
@ -1780,27 +1780,27 @@ namespace libtorrent
|
|||
{
|
||||
m_storage->move_slot(other_slot, m_current_slot);
|
||||
}
|
||||
assert(m_slot_to_piece[m_current_slot] == unassigned
|
||||
TORRENT_ASSERT(m_slot_to_piece[m_current_slot] == unassigned
|
||||
|| m_piece_to_slot[m_slot_to_piece[m_current_slot]] == m_current_slot);
|
||||
}
|
||||
else if (this_should_move && other_should_move)
|
||||
{
|
||||
assert(piece_index != m_current_slot);
|
||||
assert(piece_index >= 0);
|
||||
TORRENT_ASSERT(piece_index != m_current_slot);
|
||||
TORRENT_ASSERT(piece_index >= 0);
|
||||
|
||||
const int piece1 = m_slot_to_piece[piece_index];
|
||||
const int piece2 = m_current_slot;
|
||||
const int slot1 = piece_index;
|
||||
const int slot2 = m_piece_to_slot[piece2];
|
||||
|
||||
assert(slot1 >= 0);
|
||||
assert(slot2 >= 0);
|
||||
assert(piece2 >= 0);
|
||||
TORRENT_ASSERT(slot1 >= 0);
|
||||
TORRENT_ASSERT(slot2 >= 0);
|
||||
TORRENT_ASSERT(piece2 >= 0);
|
||||
|
||||
if (slot1 == slot2)
|
||||
{
|
||||
// this means there are only two pieces involved in the swap
|
||||
assert(piece1 >= 0);
|
||||
TORRENT_ASSERT(piece1 >= 0);
|
||||
|
||||
// movement diagram:
|
||||
// +-------------------------------+
|
||||
|
@ -1813,18 +1813,18 @@ namespace libtorrent
|
|||
m_piece_to_slot[piece_index] = slot1;
|
||||
m_piece_to_slot[piece1] = m_current_slot;
|
||||
|
||||
assert(piece1 == m_current_slot);
|
||||
assert(piece_index == slot1);
|
||||
TORRENT_ASSERT(piece1 == m_current_slot);
|
||||
TORRENT_ASSERT(piece_index == slot1);
|
||||
|
||||
m_storage->swap_slots(m_current_slot, slot1);
|
||||
|
||||
assert(m_slot_to_piece[m_current_slot] == unassigned
|
||||
TORRENT_ASSERT(m_slot_to_piece[m_current_slot] == unassigned
|
||||
|| m_piece_to_slot[m_slot_to_piece[m_current_slot]] == m_current_slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(slot1 != slot2);
|
||||
assert(piece1 != piece2);
|
||||
TORRENT_ASSERT(slot1 != slot2);
|
||||
TORRENT_ASSERT(piece1 != piece2);
|
||||
|
||||
// movement diagram:
|
||||
// +-----------------------------------------+
|
||||
|
@ -1842,7 +1842,7 @@ namespace libtorrent
|
|||
{
|
||||
std::vector<int>::iterator i =
|
||||
std::find(m_free_slots.begin(), m_free_slots.end(), slot1);
|
||||
assert(i != m_free_slots.end());
|
||||
TORRENT_ASSERT(i != m_free_slots.end());
|
||||
m_free_slots.erase(i);
|
||||
m_free_slots.push_back(slot2);
|
||||
}
|
||||
|
@ -1858,15 +1858,15 @@ namespace libtorrent
|
|||
m_storage->move_slot(slot2, m_current_slot);
|
||||
}
|
||||
|
||||
assert(m_slot_to_piece[m_current_slot] == unassigned
|
||||
TORRENT_ASSERT(m_slot_to_piece[m_current_slot] == unassigned
|
||||
|| m_piece_to_slot[m_slot_to_piece[m_current_slot]] == m_current_slot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(m_piece_to_slot[m_current_slot] == has_no_slot || piece_index != m_current_slot);
|
||||
assert(m_slot_to_piece[m_current_slot] == unallocated);
|
||||
assert(piece_index == unassigned || m_piece_to_slot[piece_index] == has_no_slot);
|
||||
TORRENT_ASSERT(m_piece_to_slot[m_current_slot] == has_no_slot || piece_index != m_current_slot);
|
||||
TORRENT_ASSERT(m_slot_to_piece[m_current_slot] == unallocated);
|
||||
TORRENT_ASSERT(piece_index == unassigned || m_piece_to_slot[piece_index] == has_no_slot);
|
||||
|
||||
// the slot was identified as piece 'piece_index'
|
||||
if (piece_index != unassigned)
|
||||
|
@ -1876,7 +1876,7 @@ namespace libtorrent
|
|||
|
||||
m_slot_to_piece[m_current_slot] = piece_index;
|
||||
|
||||
assert(m_slot_to_piece[m_current_slot] == unassigned
|
||||
TORRENT_ASSERT(m_slot_to_piece[m_current_slot] == unassigned
|
||||
|| m_piece_to_slot[m_slot_to_piece[m_current_slot]] == m_current_slot);
|
||||
}
|
||||
}
|
||||
|
@ -1892,14 +1892,14 @@ namespace libtorrent
|
|||
if (file_offset > current_offset) break;
|
||||
}
|
||||
|
||||
assert(file_offset > current_offset);
|
||||
TORRENT_ASSERT(file_offset > current_offset);
|
||||
int skip_blocks = static_cast<int>(
|
||||
(file_offset - current_offset + m_info->piece_length() - 1)
|
||||
/ m_info->piece_length());
|
||||
|
||||
for (int i = m_current_slot; i < m_current_slot + skip_blocks; ++i)
|
||||
{
|
||||
assert(m_slot_to_piece[i] == unallocated);
|
||||
TORRENT_ASSERT(m_slot_to_piece[i] == unallocated);
|
||||
m_unallocated_slots.push_back(i);
|
||||
}
|
||||
|
||||
|
@ -1910,17 +1910,17 @@ namespace libtorrent
|
|||
|
||||
if (m_current_slot >= m_info->num_pieces())
|
||||
{
|
||||
assert(m_current_slot == m_info->num_pieces());
|
||||
TORRENT_ASSERT(m_current_slot == m_info->num_pieces());
|
||||
|
||||
// clear the memory we've been using
|
||||
std::vector<char>().swap(m_piece_data);
|
||||
std::multimap<sha1_hash, int>().swap(m_hash_to_piece);
|
||||
m_state = state_allocating;
|
||||
assert(num_pieces == std::count(pieces.begin(), pieces.end(), true));
|
||||
TORRENT_ASSERT(num_pieces == std::count(pieces.begin(), pieces.end(), true));
|
||||
return std::make_pair(false, 1.f);
|
||||
}
|
||||
|
||||
assert(num_pieces == std::count(pieces.begin(), pieces.end(), true));
|
||||
TORRENT_ASSERT(num_pieces == std::count(pieces.begin(), pieces.end(), true));
|
||||
|
||||
return std::make_pair(false, (float)m_current_slot / m_info->num_pieces());
|
||||
}
|
||||
|
@ -1931,23 +1931,23 @@ namespace libtorrent
|
|||
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(piece_index >= 0);
|
||||
assert(piece_index < (int)m_piece_to_slot.size());
|
||||
assert(m_piece_to_slot.size() == m_slot_to_piece.size());
|
||||
TORRENT_ASSERT(piece_index >= 0);
|
||||
TORRENT_ASSERT(piece_index < (int)m_piece_to_slot.size());
|
||||
TORRENT_ASSERT(m_piece_to_slot.size() == m_slot_to_piece.size());
|
||||
|
||||
int slot_index = m_piece_to_slot[piece_index];
|
||||
|
||||
if (slot_index != has_no_slot)
|
||||
{
|
||||
assert(slot_index >= 0);
|
||||
assert(slot_index < (int)m_slot_to_piece.size());
|
||||
TORRENT_ASSERT(slot_index >= 0);
|
||||
TORRENT_ASSERT(slot_index < (int)m_slot_to_piece.size());
|
||||
return slot_index;
|
||||
}
|
||||
|
||||
if (m_free_slots.empty())
|
||||
{
|
||||
allocate_slots(1);
|
||||
assert(!m_free_slots.empty());
|
||||
TORRENT_ASSERT(!m_free_slots.empty());
|
||||
}
|
||||
|
||||
std::vector<int>::iterator iter(
|
||||
|
@ -1958,8 +1958,8 @@ namespace libtorrent
|
|||
|
||||
if (iter == m_free_slots.end())
|
||||
{
|
||||
assert(m_slot_to_piece[piece_index] != unassigned);
|
||||
assert(!m_free_slots.empty());
|
||||
TORRENT_ASSERT(m_slot_to_piece[piece_index] != unassigned);
|
||||
TORRENT_ASSERT(!m_free_slots.empty());
|
||||
iter = m_free_slots.end() - 1;
|
||||
|
||||
// special case to make sure we don't use the last slot
|
||||
|
@ -1968,7 +1968,7 @@ namespace libtorrent
|
|||
{
|
||||
if (m_free_slots.size() == 1)
|
||||
allocate_slots(1);
|
||||
assert(m_free_slots.size() > 1);
|
||||
TORRENT_ASSERT(m_free_slots.size() > 1);
|
||||
// assumes that all allocated slots
|
||||
// are put at the end of the free_slots vector
|
||||
iter = m_free_slots.end() - 1;
|
||||
|
@ -1978,7 +1978,7 @@ namespace libtorrent
|
|||
slot_index = *iter;
|
||||
m_free_slots.erase(iter);
|
||||
|
||||
assert(m_slot_to_piece[slot_index] == unassigned);
|
||||
TORRENT_ASSERT(m_slot_to_piece[slot_index] == unassigned);
|
||||
|
||||
m_slot_to_piece[slot_index] = piece_index;
|
||||
m_piece_to_slot[piece_index] = slot_index;
|
||||
|
@ -2007,7 +2007,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
int piece_at_our_slot = m_slot_to_piece[piece_index];
|
||||
assert(m_piece_to_slot[piece_at_our_slot] == piece_index);
|
||||
TORRENT_ASSERT(m_piece_to_slot[piece_at_our_slot] == piece_index);
|
||||
|
||||
std::swap(
|
||||
m_slot_to_piece[piece_index]
|
||||
|
@ -2019,8 +2019,8 @@ namespace libtorrent
|
|||
|
||||
m_storage->move_slot(piece_index, slot_index);
|
||||
|
||||
assert(m_slot_to_piece[piece_index] == piece_index);
|
||||
assert(m_piece_to_slot[piece_index] == piece_index);
|
||||
TORRENT_ASSERT(m_slot_to_piece[piece_index] == piece_index);
|
||||
TORRENT_ASSERT(m_piece_to_slot[piece_index] == piece_index);
|
||||
|
||||
slot_index = piece_index;
|
||||
|
||||
|
@ -2029,20 +2029,20 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
assert(slot_index >= 0);
|
||||
assert(slot_index < (int)m_slot_to_piece.size());
|
||||
TORRENT_ASSERT(slot_index >= 0);
|
||||
TORRENT_ASSERT(slot_index < (int)m_slot_to_piece.size());
|
||||
return slot_index;
|
||||
}
|
||||
|
||||
bool piece_manager::allocate_slots(int num_slots, bool abort_on_disk)
|
||||
{
|
||||
assert(num_slots > 0);
|
||||
TORRENT_ASSERT(num_slots > 0);
|
||||
|
||||
boost::recursive_mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(!m_unallocated_slots.empty());
|
||||
TORRENT_ASSERT(!m_unallocated_slots.empty());
|
||||
|
||||
const int stack_buffer_size = 16*1024;
|
||||
char zeroes[stack_buffer_size];
|
||||
|
@ -2055,8 +2055,8 @@ namespace libtorrent
|
|||
// INVARIANT_CHECK;
|
||||
|
||||
int pos = m_unallocated_slots.front();
|
||||
assert(m_slot_to_piece[pos] == unallocated);
|
||||
assert(m_piece_to_slot[pos] != pos);
|
||||
TORRENT_ASSERT(m_slot_to_piece[pos] == unallocated);
|
||||
TORRENT_ASSERT(m_piece_to_slot[pos] != pos);
|
||||
|
||||
int new_free_slot = pos;
|
||||
if (m_piece_to_slot[pos] != has_no_slot)
|
||||
|
@ -2085,7 +2085,7 @@ namespace libtorrent
|
|||
if (abort_on_disk && written) return true;
|
||||
}
|
||||
|
||||
assert(m_free_slots.size() > 0);
|
||||
TORRENT_ASSERT(m_free_slots.size() > 0);
|
||||
return written;
|
||||
}
|
||||
|
||||
|
@ -2095,26 +2095,26 @@ namespace libtorrent
|
|||
boost::recursive_mutex::scoped_lock lock(m_mutex);
|
||||
if (m_piece_to_slot.empty()) return;
|
||||
|
||||
assert((int)m_piece_to_slot.size() == m_info->num_pieces());
|
||||
assert((int)m_slot_to_piece.size() == m_info->num_pieces());
|
||||
TORRENT_ASSERT((int)m_piece_to_slot.size() == m_info->num_pieces());
|
||||
TORRENT_ASSERT((int)m_slot_to_piece.size() == m_info->num_pieces());
|
||||
|
||||
for (std::vector<int>::const_iterator i = m_free_slots.begin();
|
||||
i != m_free_slots.end(); ++i)
|
||||
{
|
||||
assert(*i < (int)m_slot_to_piece.size());
|
||||
assert(*i >= 0);
|
||||
assert(m_slot_to_piece[*i] == unassigned);
|
||||
assert(std::find(i+1, m_free_slots.end(), *i)
|
||||
TORRENT_ASSERT(*i < (int)m_slot_to_piece.size());
|
||||
TORRENT_ASSERT(*i >= 0);
|
||||
TORRENT_ASSERT(m_slot_to_piece[*i] == unassigned);
|
||||
TORRENT_ASSERT(std::find(i+1, m_free_slots.end(), *i)
|
||||
== m_free_slots.end());
|
||||
}
|
||||
|
||||
for (std::vector<int>::const_iterator i = m_unallocated_slots.begin();
|
||||
i != m_unallocated_slots.end(); ++i)
|
||||
{
|
||||
assert(*i < (int)m_slot_to_piece.size());
|
||||
assert(*i >= 0);
|
||||
assert(m_slot_to_piece[*i] == unallocated);
|
||||
assert(std::find(i+1, m_unallocated_slots.end(), *i)
|
||||
TORRENT_ASSERT(*i < (int)m_slot_to_piece.size());
|
||||
TORRENT_ASSERT(*i >= 0);
|
||||
TORRENT_ASSERT(m_slot_to_piece[*i] == unallocated);
|
||||
TORRENT_ASSERT(std::find(i+1, m_unallocated_slots.end(), *i)
|
||||
== m_unallocated_slots.end());
|
||||
}
|
||||
|
||||
|
@ -2123,46 +2123,46 @@ namespace libtorrent
|
|||
// Check domain of piece_to_slot's elements
|
||||
if (m_piece_to_slot[i] != has_no_slot)
|
||||
{
|
||||
assert(m_piece_to_slot[i] >= 0);
|
||||
assert(m_piece_to_slot[i] < (int)m_slot_to_piece.size());
|
||||
TORRENT_ASSERT(m_piece_to_slot[i] >= 0);
|
||||
TORRENT_ASSERT(m_piece_to_slot[i] < (int)m_slot_to_piece.size());
|
||||
}
|
||||
|
||||
// Check domain of slot_to_piece's elements
|
||||
if (m_slot_to_piece[i] != unallocated
|
||||
&& m_slot_to_piece[i] != unassigned)
|
||||
{
|
||||
assert(m_slot_to_piece[i] >= 0);
|
||||
assert(m_slot_to_piece[i] < (int)m_piece_to_slot.size());
|
||||
TORRENT_ASSERT(m_slot_to_piece[i] >= 0);
|
||||
TORRENT_ASSERT(m_slot_to_piece[i] < (int)m_piece_to_slot.size());
|
||||
}
|
||||
|
||||
// do more detailed checks on piece_to_slot
|
||||
if (m_piece_to_slot[i] >= 0)
|
||||
{
|
||||
assert(m_slot_to_piece[m_piece_to_slot[i]] == i);
|
||||
TORRENT_ASSERT(m_slot_to_piece[m_piece_to_slot[i]] == i);
|
||||
if (m_piece_to_slot[i] != i)
|
||||
{
|
||||
assert(m_slot_to_piece[i] == unallocated);
|
||||
TORRENT_ASSERT(m_slot_to_piece[i] == unallocated);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(m_piece_to_slot[i] == has_no_slot);
|
||||
TORRENT_ASSERT(m_piece_to_slot[i] == has_no_slot);
|
||||
}
|
||||
|
||||
// do more detailed checks on slot_to_piece
|
||||
|
||||
if (m_slot_to_piece[i] >= 0)
|
||||
{
|
||||
assert(m_slot_to_piece[i] < (int)m_piece_to_slot.size());
|
||||
assert(m_piece_to_slot[m_slot_to_piece[i]] == i);
|
||||
TORRENT_ASSERT(m_slot_to_piece[i] < (int)m_piece_to_slot.size());
|
||||
TORRENT_ASSERT(m_piece_to_slot[m_slot_to_piece[i]] == i);
|
||||
#ifdef TORRENT_STORAGE_DEBUG
|
||||
assert(
|
||||
TORRENT_ASSERT(
|
||||
std::find(
|
||||
m_unallocated_slots.begin()
|
||||
, m_unallocated_slots.end()
|
||||
, i) == m_unallocated_slots.end()
|
||||
);
|
||||
assert(
|
||||
TORRENT_ASSERT(
|
||||
std::find(
|
||||
m_free_slots.begin()
|
||||
, m_free_slots.end()
|
||||
|
@ -2173,7 +2173,7 @@ namespace libtorrent
|
|||
else if (m_slot_to_piece[i] == unallocated)
|
||||
{
|
||||
#ifdef TORRENT_STORAGE_DEBUG
|
||||
assert(m_unallocated_slots.empty()
|
||||
TORRENT_ASSERT(m_unallocated_slots.empty()
|
||||
|| (std::find(
|
||||
m_unallocated_slots.begin()
|
||||
, m_unallocated_slots.end()
|
||||
|
@ -2184,7 +2184,7 @@ namespace libtorrent
|
|||
else if (m_slot_to_piece[i] == unassigned)
|
||||
{
|
||||
#ifdef TORRENT_STORAGE_DEBUG
|
||||
assert(
|
||||
TORRENT_ASSERT(
|
||||
std::find(
|
||||
m_free_slots.begin()
|
||||
, m_free_slots.end()
|
||||
|
@ -2194,7 +2194,7 @@ namespace libtorrent
|
|||
}
|
||||
else
|
||||
{
|
||||
assert(false && "m_slot_to_piece[i] is invalid");
|
||||
TORRENT_ASSERT(false && "m_slot_to_piece[i] is invalid");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace
|
|||
find_peer_by_ip(tcp::endpoint const& a, const torrent* t)
|
||||
: ip(a)
|
||||
, tor(t)
|
||||
{ assert(t != 0); }
|
||||
{ TORRENT_ASSERT(t != 0); }
|
||||
|
||||
bool operator()(const session_impl::connection_map::value_type& c) const
|
||||
{
|
||||
|
@ -309,7 +309,7 @@ namespace libtorrent
|
|||
// been closed by the time the torrent is destructed. And they are
|
||||
// supposed to be closed. So we can still do the invariant check.
|
||||
|
||||
assert(m_connections.empty());
|
||||
TORRENT_ASSERT(m_connections.empty());
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
@ -321,7 +321,7 @@ namespace libtorrent
|
|||
}
|
||||
#endif
|
||||
|
||||
assert(m_abort);
|
||||
TORRENT_ASSERT(m_abort);
|
||||
if (!m_connections.empty())
|
||||
disconnect_all();
|
||||
}
|
||||
|
@ -344,9 +344,9 @@ namespace libtorrent
|
|||
// shared_from_this()
|
||||
void torrent::init()
|
||||
{
|
||||
assert(m_torrent_file->is_valid());
|
||||
assert(m_torrent_file->num_files() > 0);
|
||||
assert(m_torrent_file->total_size() >= 0);
|
||||
TORRENT_ASSERT(m_torrent_file->is_valid());
|
||||
TORRENT_ASSERT(m_torrent_file->num_files() > 0);
|
||||
TORRENT_ASSERT(m_torrent_file->total_size() >= 0);
|
||||
|
||||
m_have_pieces.resize(m_torrent_file->num_pieces(), false);
|
||||
// the shared_from_this() will create an intentional
|
||||
|
@ -423,7 +423,7 @@ namespace libtorrent
|
|||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -662,7 +662,7 @@ namespace libtorrent
|
|||
|
||||
size_type total_done
|
||||
= m_num_pieces * m_torrent_file->piece_length();
|
||||
assert(m_num_pieces < m_torrent_file->num_pieces());
|
||||
TORRENT_ASSERT(m_num_pieces < m_torrent_file->num_pieces());
|
||||
|
||||
// if we have the last piece, we have to correct
|
||||
// the amount we have, since the first calculation
|
||||
|
@ -676,8 +676,8 @@ namespace libtorrent
|
|||
wanted_done += corr;
|
||||
}
|
||||
|
||||
assert(total_done <= m_torrent_file->total_size());
|
||||
assert(wanted_done <= m_torrent_file->total_size());
|
||||
TORRENT_ASSERT(total_done <= m_torrent_file->total_size());
|
||||
TORRENT_ASSERT(wanted_done <= m_torrent_file->total_size());
|
||||
|
||||
const std::vector<piece_picker::downloading_piece>& dl_queue
|
||||
= m_picker->get_download_queue();
|
||||
|
@ -690,22 +690,22 @@ namespace libtorrent
|
|||
{
|
||||
int corr = 0;
|
||||
int index = i->index;
|
||||
assert(!m_have_pieces[index]);
|
||||
assert(i->finished <= m_picker->blocks_in_piece(index));
|
||||
if (m_have_pieces[index]) continue;
|
||||
TORRENT_ASSERT(i->finished <= m_picker->blocks_in_piece(index));
|
||||
|
||||
#ifndef NDEBUG
|
||||
for (std::vector<piece_picker::downloading_piece>::const_iterator j = boost::next(i);
|
||||
j != dl_queue.end(); ++j)
|
||||
{
|
||||
assert(j->index != index);
|
||||
TORRENT_ASSERT(j->index != index);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int j = 0; j < blocks_per_piece; ++j)
|
||||
{
|
||||
assert(m_picker->is_finished(piece_block(index, j)) == (i->info[j].state == piece_picker::block_info::state_finished));
|
||||
TORRENT_ASSERT(m_picker->is_finished(piece_block(index, j)) == (i->info[j].state == piece_picker::block_info::state_finished));
|
||||
corr += (i->info[j].state == piece_picker::block_info::state_finished) * m_block_size;
|
||||
assert(index != last_piece || j < m_picker->blocks_in_last_piece()
|
||||
TORRENT_ASSERT(index != last_piece || j < m_picker->blocks_in_last_piece()
|
||||
|| i->info[j].state != piece_picker::block_info::state_finished);
|
||||
}
|
||||
|
||||
|
@ -723,8 +723,8 @@ namespace libtorrent
|
|||
wanted_done += corr;
|
||||
}
|
||||
|
||||
assert(total_done <= m_torrent_file->total_size());
|
||||
assert(wanted_done <= m_torrent_file->total_size());
|
||||
TORRENT_ASSERT(total_done <= m_torrent_file->total_size());
|
||||
TORRENT_ASSERT(wanted_done <= m_torrent_file->total_size());
|
||||
|
||||
std::map<piece_block, int> downloading_piece;
|
||||
for (const_peer_iterator i = begin(); i != end(); ++i)
|
||||
|
@ -753,13 +753,13 @@ namespace libtorrent
|
|||
downloading_piece[block] = p->bytes_downloaded;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
assert(p->bytes_downloaded <= p->full_block_bytes);
|
||||
TORRENT_ASSERT(p->bytes_downloaded <= p->full_block_bytes);
|
||||
int last_piece = m_torrent_file->num_pieces() - 1;
|
||||
if (p->piece_index == last_piece
|
||||
&& p->block_index == m_torrent_file->piece_size(last_piece) / block_size())
|
||||
assert(p->full_block_bytes == m_torrent_file->piece_size(last_piece) % block_size());
|
||||
TORRENT_ASSERT(p->full_block_bytes == m_torrent_file->piece_size(last_piece) % block_size());
|
||||
else
|
||||
assert(p->full_block_bytes == block_size());
|
||||
TORRENT_ASSERT(p->full_block_bytes == block_size());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -806,12 +806,12 @@ namespace libtorrent
|
|||
|
||||
}
|
||||
|
||||
assert(total_done <= m_torrent_file->total_size());
|
||||
assert(wanted_done <= m_torrent_file->total_size());
|
||||
TORRENT_ASSERT(total_done <= m_torrent_file->total_size());
|
||||
TORRENT_ASSERT(wanted_done <= m_torrent_file->total_size());
|
||||
|
||||
#endif
|
||||
|
||||
assert(total_done >= wanted_done);
|
||||
TORRENT_ASSERT(total_done >= wanted_done);
|
||||
return make_tuple(total_done, wanted_done);
|
||||
}
|
||||
|
||||
|
@ -833,7 +833,7 @@ namespace libtorrent
|
|||
// the following call may cause picker to become invalid
|
||||
// in case we just became a seed
|
||||
announce_piece(index);
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
// if we just became a seed, picker is now invalid, since it
|
||||
// is deallocated by the torrent once it starts seeding
|
||||
if (!was_finished
|
||||
|
@ -850,7 +850,7 @@ namespace libtorrent
|
|||
{
|
||||
#ifndef NDEBUG
|
||||
std::cerr << e.what() << std::endl;
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -872,7 +872,7 @@ namespace libtorrent
|
|||
catch (std::exception const& e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -883,7 +883,7 @@ namespace libtorrent
|
|||
|
||||
if (!was_seed && is_seed())
|
||||
{
|
||||
assert(passed_hash_check);
|
||||
TORRENT_ASSERT(passed_hash_check);
|
||||
completed();
|
||||
}
|
||||
|
||||
|
@ -892,7 +892,7 @@ namespace libtorrent
|
|||
catch (std::exception const& e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -907,11 +907,11 @@ namespace libtorrent
|
|||
// (total_done == m_torrent_file->total_size()) => is_seed()
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(m_storage);
|
||||
assert(m_storage->refcount() > 0);
|
||||
assert(m_picker.get());
|
||||
assert(index >= 0);
|
||||
assert(index < m_torrent_file->num_pieces());
|
||||
TORRENT_ASSERT(m_storage);
|
||||
TORRENT_ASSERT(m_storage->refcount() > 0);
|
||||
TORRENT_ASSERT(m_picker.get());
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < m_torrent_file->num_pieces());
|
||||
|
||||
if (m_ses.m_alerts.should_post(alert::info))
|
||||
{
|
||||
|
@ -949,7 +949,7 @@ namespace libtorrent
|
|||
{
|
||||
std::vector<peer_connection*> conns;
|
||||
connection_for(p->ip.address(), conns);
|
||||
assert(p->connection == 0
|
||||
TORRENT_ASSERT(p->connection == 0
|
||||
|| std::find_if(conns.begin(), conns.end()
|
||||
, boost::bind(std::equal_to<peer_connection*>(), _1, p->connection))
|
||||
!= conns.end());
|
||||
|
@ -997,10 +997,10 @@ namespace libtorrent
|
|||
// start with redownloading the pieces that the client
|
||||
// that has sent the least number of pieces
|
||||
m_picker->restore_piece(index);
|
||||
assert(m_storage);
|
||||
TORRENT_ASSERT(m_storage);
|
||||
m_storage->mark_failed(index);
|
||||
|
||||
assert(m_have_pieces[index] == false);
|
||||
TORRENT_ASSERT(m_have_pieces[index] == false);
|
||||
}
|
||||
|
||||
void torrent::abort()
|
||||
|
@ -1057,8 +1057,8 @@ namespace libtorrent
|
|||
{
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(index >= 0);
|
||||
assert(index < m_torrent_file->num_pieces());
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < m_torrent_file->num_pieces());
|
||||
|
||||
std::vector<void*> downloaders;
|
||||
m_picker->get_downloaders(downloaders, index);
|
||||
|
@ -1072,7 +1072,7 @@ namespace libtorrent
|
|||
m_num_pieces++;
|
||||
m_have_pieces[index] = true;
|
||||
|
||||
assert(std::accumulate(m_have_pieces.begin(), m_have_pieces.end(), 0)
|
||||
TORRENT_ASSERT(std::accumulate(m_have_pieces.begin(), m_have_pieces.end(), 0)
|
||||
== m_num_pieces);
|
||||
|
||||
m_picker->we_have(index);
|
||||
|
@ -1115,7 +1115,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
if (is_seed())
|
||||
{
|
||||
avail.clear();
|
||||
|
@ -1129,13 +1129,13 @@ namespace libtorrent
|
|||
{
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
if (is_seed()) return;
|
||||
|
||||
// this call is only valid on torrents with metadata
|
||||
assert(m_picker.get());
|
||||
assert(index >= 0);
|
||||
assert(index < m_torrent_file->num_pieces());
|
||||
TORRENT_ASSERT(m_picker.get());
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < m_torrent_file->num_pieces());
|
||||
|
||||
bool filter_updated = m_picker->set_piece_priority(index, priority);
|
||||
if (filter_updated) update_peer_interest();
|
||||
|
@ -1145,13 +1145,13 @@ namespace libtorrent
|
|||
{
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
if (is_seed()) return 1;
|
||||
|
||||
// this call is only valid on torrents with metadata
|
||||
assert(m_picker.get());
|
||||
assert(index >= 0);
|
||||
assert(index < m_torrent_file->num_pieces());
|
||||
TORRENT_ASSERT(m_picker.get());
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < m_torrent_file->num_pieces());
|
||||
|
||||
return m_picker->piece_priority(index);
|
||||
}
|
||||
|
@ -1161,18 +1161,18 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
// this call is only valid on torrents with metadata
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
if (is_seed()) return;
|
||||
|
||||
assert(m_picker.get());
|
||||
TORRENT_ASSERT(m_picker.get());
|
||||
|
||||
int index = 0;
|
||||
bool filter_updated = false;
|
||||
for (std::vector<int>::const_iterator i = pieces.begin()
|
||||
, end(pieces.end()); i != end; ++i, ++index)
|
||||
{
|
||||
assert(*i >= 0);
|
||||
assert(*i <= 7);
|
||||
TORRENT_ASSERT(*i >= 0);
|
||||
TORRENT_ASSERT(*i <= 7);
|
||||
filter_updated |= m_picker->set_piece_priority(index, *i);
|
||||
}
|
||||
if (filter_updated) update_peer_interest();
|
||||
|
@ -1183,7 +1183,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
// this call is only valid on torrents with metadata
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
if (is_seed())
|
||||
{
|
||||
pieces.clear();
|
||||
|
@ -1191,7 +1191,7 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
assert(m_picker.get());
|
||||
TORRENT_ASSERT(m_picker.get());
|
||||
m_picker->piece_priorities(pieces);
|
||||
}
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ namespace libtorrent
|
|||
|
||||
// the bitmask need to have exactly one bit for every file
|
||||
// in the torrent
|
||||
assert(int(files.size()) == m_torrent_file->num_files());
|
||||
TORRENT_ASSERT(int(files.size()) == m_torrent_file->num_files());
|
||||
|
||||
size_type position = 0;
|
||||
|
||||
|
@ -1233,7 +1233,7 @@ namespace libtorrent
|
|||
// already set (to avoid problems with overlapping pieces)
|
||||
int start_piece = int(start / piece_length);
|
||||
int last_piece = int((position - 1) / piece_length);
|
||||
assert(last_piece <= int(pieces.size()));
|
||||
TORRENT_ASSERT(last_piece <= int(pieces.size()));
|
||||
// if one piece spans several files, we might
|
||||
// come here several times with the same start_piece, end_piece
|
||||
std::for_each(pieces.begin() + start_piece
|
||||
|
@ -1255,13 +1255,13 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
if (is_seed()) return;
|
||||
|
||||
// this call is only valid on torrents with metadata
|
||||
assert(m_picker.get());
|
||||
assert(index >= 0);
|
||||
assert(index < m_torrent_file->num_pieces());
|
||||
TORRENT_ASSERT(m_picker.get());
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < m_torrent_file->num_pieces());
|
||||
|
||||
m_picker->set_piece_priority(index, filter ? 1 : 0);
|
||||
update_peer_interest();
|
||||
|
@ -1272,10 +1272,10 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
// this call is only valid on torrents with metadata
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
if (is_seed()) return;
|
||||
|
||||
assert(m_picker.get());
|
||||
TORRENT_ASSERT(m_picker.get());
|
||||
|
||||
int index = 0;
|
||||
for (std::vector<bool>::const_iterator i = bitmask.begin()
|
||||
|
@ -1293,12 +1293,12 @@ namespace libtorrent
|
|||
bool torrent::is_piece_filtered(int index) const
|
||||
{
|
||||
// this call is only valid on torrents with metadata
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
if (is_seed()) return false;
|
||||
|
||||
assert(m_picker.get());
|
||||
assert(index >= 0);
|
||||
assert(index < m_torrent_file->num_pieces());
|
||||
TORRENT_ASSERT(m_picker.get());
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < m_torrent_file->num_pieces());
|
||||
|
||||
return m_picker->piece_priority(index) == 0;
|
||||
}
|
||||
|
@ -1308,7 +1308,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
// this call is only valid on torrents with metadata
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
if (is_seed())
|
||||
{
|
||||
bitmask.clear();
|
||||
|
@ -1316,7 +1316,7 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
assert(m_picker.get());
|
||||
TORRENT_ASSERT(m_picker.get());
|
||||
m_picker->filtered_pieces(bitmask);
|
||||
}
|
||||
|
||||
|
@ -1329,7 +1329,7 @@ namespace libtorrent
|
|||
|
||||
// the bitmask need to have exactly one bit for every file
|
||||
// in the torrent
|
||||
assert((int)bitmask.size() == m_torrent_file->num_files());
|
||||
TORRENT_ASSERT((int)bitmask.size() == m_torrent_file->num_files());
|
||||
|
||||
size_type position = 0;
|
||||
|
||||
|
@ -1361,7 +1361,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::replace_trackers(std::vector<announce_entry> const& urls)
|
||||
{
|
||||
assert(!urls.empty());
|
||||
TORRENT_ASSERT(!urls.empty());
|
||||
m_trackers = urls;
|
||||
if (m_currently_trying_tracker >= (int)m_trackers.size())
|
||||
m_currently_trying_tracker = (int)m_trackers.size()-1;
|
||||
|
@ -1372,7 +1372,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!m_trackers.empty());
|
||||
TORRENT_ASSERT(!m_trackers.empty());
|
||||
|
||||
m_next_request = time_now() + seconds(tracker_retry_delay_max);
|
||||
|
||||
|
@ -1408,8 +1408,8 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!c.is_choked());
|
||||
assert(m_num_uploads > 0);
|
||||
TORRENT_ASSERT(!c.is_choked());
|
||||
TORRENT_ASSERT(m_num_uploads > 0);
|
||||
c.send_choke();
|
||||
--m_num_uploads;
|
||||
}
|
||||
|
@ -1418,7 +1418,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(c.is_choked());
|
||||
TORRENT_ASSERT(c.is_choked());
|
||||
if (m_num_uploads >= m_max_uploads) return false;
|
||||
c.send_unchoke();
|
||||
++m_num_uploads;
|
||||
|
@ -1438,24 +1438,24 @@ namespace libtorrent
|
|||
{
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(p != 0);
|
||||
TORRENT_ASSERT(p != 0);
|
||||
|
||||
peer_iterator i = m_connections.find(p->remote());
|
||||
if (i == m_connections.end())
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ready_for_connections())
|
||||
{
|
||||
assert(p->associated_torrent().lock().get() == this);
|
||||
TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
|
||||
|
||||
if (p->is_seed())
|
||||
{
|
||||
if (m_picker.get())
|
||||
{
|
||||
assert(!is_seed());
|
||||
TORRENT_ASSERT(!is_seed());
|
||||
m_picker->dec_refcount_all();
|
||||
}
|
||||
}
|
||||
|
@ -1487,7 +1487,7 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
std::string err = e.what();
|
||||
#endif
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
|
||||
void torrent::connect_to_url_seed(std::string const& url)
|
||||
|
@ -1582,7 +1582,7 @@ namespace libtorrent
|
|||
}
|
||||
catch (std::exception& exc)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
|
||||
void torrent::on_name_lookup(asio::error_code const& e, tcp::resolver::iterator host
|
||||
|
@ -1667,10 +1667,10 @@ namespace libtorrent
|
|||
|
||||
try
|
||||
{
|
||||
assert(m_connections.find(a) == m_connections.end());
|
||||
TORRENT_ASSERT(m_connections.find(a) == m_connections.end());
|
||||
|
||||
// add the newly connected peer to this torrent's peer list
|
||||
assert(m_connections.find(a) == m_connections.end());
|
||||
TORRENT_ASSERT(m_connections.find(a) == m_connections.end());
|
||||
m_connections.insert(
|
||||
std::make_pair(a, boost::get_pointer(c)));
|
||||
m_ses.m_connections.insert(std::make_pair(s, c));
|
||||
|
@ -1698,7 +1698,7 @@ namespace libtorrent
|
|||
#ifndef NDEBUG
|
||||
std::cerr << exc.what() << std::endl;
|
||||
#endif
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
|
||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
|
@ -1838,22 +1838,22 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(peerinfo);
|
||||
assert(peerinfo->connection == 0);
|
||||
TORRENT_ASSERT(peerinfo);
|
||||
TORRENT_ASSERT(peerinfo->connection == 0);
|
||||
#ifndef NDEBUG
|
||||
// this asserts that we don't have duplicates in the policy's peer list
|
||||
peer_iterator i_ = m_connections.find(peerinfo->ip);
|
||||
assert(i_ == m_connections.end()
|
||||
TORRENT_ASSERT(i_ == m_connections.end()
|
||||
|| i_->second->is_disconnecting()
|
||||
|| dynamic_cast<bt_peer_connection*>(i_->second) == 0
|
||||
|| m_ses.settings().allow_multiple_connections_per_ip);
|
||||
#endif
|
||||
|
||||
assert(want_more_peers());
|
||||
assert(m_ses.num_connections() < m_ses.max_connections());
|
||||
TORRENT_ASSERT(want_more_peers());
|
||||
TORRENT_ASSERT(m_ses.num_connections() < m_ses.max_connections());
|
||||
|
||||
tcp::endpoint const& a(peerinfo->ip);
|
||||
assert((m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked) == 0);
|
||||
TORRENT_ASSERT((m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked) == 0);
|
||||
|
||||
boost::shared_ptr<socket_type> s
|
||||
= instantiate_connection(m_ses.m_io_service, m_ses.peer_proxy());
|
||||
|
@ -1875,7 +1875,7 @@ namespace libtorrent
|
|||
|
||||
try
|
||||
{
|
||||
assert(m_connections.find(a) == m_connections.end());
|
||||
TORRENT_ASSERT(m_connections.find(a) == m_connections.end());
|
||||
|
||||
// add the newly connected peer to this torrent's peer list
|
||||
m_connections.insert(
|
||||
|
@ -1889,7 +1889,7 @@ namespace libtorrent
|
|||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
// TODO: post an error alert!
|
||||
std::map<tcp::endpoint, peer_connection*>::iterator i = m_connections.find(a);
|
||||
if (i != m_connections.end()) m_connections.erase(i);
|
||||
|
@ -1905,7 +1905,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(!m_torrent_file->is_valid());
|
||||
TORRENT_ASSERT(!m_torrent_file->is_valid());
|
||||
m_torrent_file->parse_info_section(metadata);
|
||||
|
||||
init();
|
||||
|
@ -1922,7 +1922,7 @@ namespace libtorrent
|
|||
typedef session_impl::torrent_map torrent_map;
|
||||
torrent_map::iterator i = m_ses.m_torrents.find(
|
||||
m_torrent_file->info_hash());
|
||||
assert(i != m_ses.m_torrents.end());
|
||||
TORRENT_ASSERT(i != m_ses.m_torrents.end());
|
||||
m_ses.m_torrents.erase(i);
|
||||
// and notify the thread that it got another
|
||||
// job in its queue
|
||||
|
@ -1939,14 +1939,14 @@ namespace libtorrent
|
|||
{
|
||||
// INVARIANT_CHECK;
|
||||
|
||||
assert(p != 0);
|
||||
assert(!p->is_local());
|
||||
TORRENT_ASSERT(p != 0);
|
||||
TORRENT_ASSERT(!p->is_local());
|
||||
|
||||
std::map<tcp::endpoint, peer_connection*>::iterator c
|
||||
= m_connections.find(p->remote());
|
||||
if (c != m_connections.end())
|
||||
{
|
||||
assert(p != c->second);
|
||||
TORRENT_ASSERT(p != c->second);
|
||||
// we already have a peer_connection to this ip.
|
||||
// It may currently be waiting for completing a
|
||||
// connection attempt that might fail. So,
|
||||
|
@ -1970,7 +1970,7 @@ namespace libtorrent
|
|||
throw protocol_error("session is closing");
|
||||
}
|
||||
|
||||
assert(m_connections.find(p->remote()) == m_connections.end());
|
||||
TORRENT_ASSERT(m_connections.find(p->remote()) == m_connections.end());
|
||||
peer_iterator ci = m_connections.insert(
|
||||
std::make_pair(p->remote(), p)).first;
|
||||
try
|
||||
|
@ -1986,8 +1986,8 @@ namespace libtorrent
|
|||
if (pp) p->add_extension(pp);
|
||||
}
|
||||
#endif
|
||||
assert(connection_for(p->remote()) == p);
|
||||
assert(ci->second == p);
|
||||
TORRENT_ASSERT(connection_for(p->remote()) == p);
|
||||
TORRENT_ASSERT(ci->second == p);
|
||||
m_policy->new_connection(*ci->second);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
@ -1995,7 +1995,7 @@ namespace libtorrent
|
|||
m_connections.erase(ci);
|
||||
throw;
|
||||
}
|
||||
assert(p->remote() == p->get_socket()->remote_endpoint());
|
||||
TORRENT_ASSERT(p->remote() == p->get_socket()->remote_endpoint());
|
||||
|
||||
#ifndef NDEBUG
|
||||
m_policy->check_invariant();
|
||||
|
@ -2018,7 +2018,7 @@ namespace libtorrent
|
|||
while (!m_connections.empty())
|
||||
{
|
||||
peer_connection& p = *m_connections.begin()->second;
|
||||
assert(p.associated_torrent().lock().get() == this);
|
||||
TORRENT_ASSERT(p.associated_torrent().lock().get() == this);
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING)
|
||||
if (m_abort)
|
||||
|
@ -2030,7 +2030,7 @@ namespace libtorrent
|
|||
std::size_t size = m_connections.size();
|
||||
#endif
|
||||
p.disconnect();
|
||||
assert(m_connections.size() <= size);
|
||||
TORRENT_ASSERT(m_connections.size() <= size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2043,7 +2043,7 @@ namespace libtorrent
|
|||
, boost::intrusive_ptr<peer_connection> const& p
|
||||
, bool non_prioritized)
|
||||
{
|
||||
assert(m_bandwidth_limit[channel].throttle() > 0);
|
||||
TORRENT_ASSERT(m_bandwidth_limit[channel].throttle() > 0);
|
||||
int block_size = m_bandwidth_limit[channel].throttle() / 10;
|
||||
if (block_size <= 0) block_size = 1;
|
||||
|
||||
|
@ -2066,7 +2066,7 @@ namespace libtorrent
|
|||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
assert(amount > 0);
|
||||
TORRENT_ASSERT(amount > 0);
|
||||
m_bandwidth_limit[channel].expire(amount);
|
||||
|
||||
while (!m_bandwidth_queue[channel].empty())
|
||||
|
@ -2094,8 +2094,8 @@ namespace libtorrent
|
|||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
assert(amount > 0);
|
||||
assert(amount <= blk);
|
||||
TORRENT_ASSERT(amount > 0);
|
||||
TORRENT_ASSERT(amount <= blk);
|
||||
if (amount < blk)
|
||||
expire_bandwidth(channel, blk - amount);
|
||||
}
|
||||
|
@ -2119,7 +2119,7 @@ namespace libtorrent
|
|||
for (peer_iterator i = m_connections.begin();
|
||||
i != m_connections.end(); ++i)
|
||||
{
|
||||
assert(i->second->associated_torrent().lock().get() == this);
|
||||
TORRENT_ASSERT(i->second->associated_torrent().lock().get() == this);
|
||||
if (i->second->is_seed())
|
||||
{
|
||||
#if defined(TORRENT_VERBOSE_LOGGING)
|
||||
|
@ -2131,7 +2131,7 @@ namespace libtorrent
|
|||
std::for_each(seeds.begin(), seeds.end()
|
||||
, bind(&peer_connection::disconnect, _1));
|
||||
|
||||
assert(m_storage);
|
||||
TORRENT_ASSERT(m_storage);
|
||||
// we need to keep the object alive during this operation
|
||||
m_storage->async_release_files(
|
||||
bind(&torrent::on_files_released, shared_from_this(), _1, _2));
|
||||
|
@ -2155,7 +2155,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(index >= 0);
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
if (index >= (int)m_trackers.size()) return (int)m_trackers.size()-1;
|
||||
|
||||
while (index > 0 && m_trackers[index].tier == m_trackers[index-1].tier)
|
||||
|
@ -2210,12 +2210,12 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
bool done = true;
|
||||
try
|
||||
{
|
||||
assert(m_storage);
|
||||
assert(m_owning_storage.get());
|
||||
TORRENT_ASSERT(m_storage);
|
||||
TORRENT_ASSERT(m_owning_storage.get());
|
||||
done = m_storage->check_fastresume(data, m_have_pieces, m_num_pieces
|
||||
, m_compact_mode);
|
||||
}
|
||||
|
@ -2239,15 +2239,15 @@ namespace libtorrent
|
|||
|
||||
std::pair<bool, float> torrent::check_files()
|
||||
{
|
||||
assert(m_torrent_file->is_valid());
|
||||
TORRENT_ASSERT(m_torrent_file->is_valid());
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_owning_storage.get());
|
||||
TORRENT_ASSERT(m_owning_storage.get());
|
||||
|
||||
std::pair<bool, float> progress(true, 1.f);
|
||||
try
|
||||
{
|
||||
assert(m_storage);
|
||||
TORRENT_ASSERT(m_storage);
|
||||
progress = m_storage->check_files(m_have_pieces, m_num_pieces
|
||||
, m_ses.m_mutex);
|
||||
}
|
||||
|
@ -2275,7 +2275,7 @@ namespace libtorrent
|
|||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
assert(m_torrent_file->is_valid());
|
||||
TORRENT_ASSERT(m_torrent_file->is_valid());
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (!is_seed())
|
||||
|
@ -2379,7 +2379,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_owning_storage.get());
|
||||
TORRENT_ASSERT(m_owning_storage.get());
|
||||
return *m_owning_storage;
|
||||
}
|
||||
|
||||
|
@ -2413,53 +2413,53 @@ namespace libtorrent
|
|||
if (!p.is_choked()) ++num_uploads;
|
||||
torrent* associated_torrent = p.associated_torrent().lock().get();
|
||||
if (associated_torrent != this)
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
assert(num_uploads == m_num_uploads);
|
||||
TORRENT_ASSERT(num_uploads == m_num_uploads);
|
||||
|
||||
if (has_picker())
|
||||
{
|
||||
for (std::map<piece_block, int>::iterator i = num_requests.begin()
|
||||
, end(num_requests.end()); i != end; ++i)
|
||||
{
|
||||
assert(m_picker->num_peers(i->first) == i->second);
|
||||
TORRENT_ASSERT(m_picker->num_peers(i->first) == i->second);
|
||||
}
|
||||
}
|
||||
|
||||
if (valid_metadata())
|
||||
{
|
||||
assert(m_abort || int(m_have_pieces.size()) == m_torrent_file->num_pieces());
|
||||
TORRENT_ASSERT(m_abort || int(m_have_pieces.size()) == m_torrent_file->num_pieces());
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(m_abort || m_have_pieces.empty());
|
||||
TORRENT_ASSERT(m_abort || m_have_pieces.empty());
|
||||
}
|
||||
|
||||
/* for (policy::const_iterator i = m_policy->begin_peer()
|
||||
, end(m_policy->end_peer()); i != end; ++i)
|
||||
{
|
||||
assert(i->connection == const_cast<torrent*>(this)->connection_for(i->ip));
|
||||
TORRENT_ASSERT(i->connection == const_cast<torrent*>(this)->connection_for(i->ip));
|
||||
}
|
||||
*/
|
||||
size_type total_done = quantized_bytes_done();
|
||||
if (m_torrent_file->is_valid())
|
||||
{
|
||||
if (is_seed())
|
||||
assert(total_done == m_torrent_file->total_size());
|
||||
TORRENT_ASSERT(total_done == m_torrent_file->total_size());
|
||||
else
|
||||
assert(total_done != m_torrent_file->total_size());
|
||||
TORRENT_ASSERT(total_done != m_torrent_file->total_size());
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(total_done == 0);
|
||||
TORRENT_ASSERT(total_done == 0);
|
||||
}
|
||||
|
||||
// This check is very expensive.
|
||||
assert(m_num_pieces
|
||||
TORRENT_ASSERT(m_num_pieces
|
||||
== std::count(m_have_pieces.begin(), m_have_pieces.end(), true));
|
||||
assert(!valid_metadata() || m_block_size > 0);
|
||||
assert(!valid_metadata() || (m_torrent_file->piece_length() % m_block_size) == 0);
|
||||
// if (is_seed()) assert(m_picker.get() == 0);
|
||||
TORRENT_ASSERT(!valid_metadata() || m_block_size > 0);
|
||||
TORRENT_ASSERT(!valid_metadata() || (m_torrent_file->piece_length() % m_block_size) == 0);
|
||||
// if (is_seed()) TORRENT_ASSERT(m_picker.get() == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2478,21 +2478,21 @@ namespace libtorrent
|
|||
|
||||
void torrent::set_max_uploads(int limit)
|
||||
{
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
if (limit <= 0) limit = (std::numeric_limits<int>::max)();
|
||||
m_max_uploads = limit;
|
||||
}
|
||||
|
||||
void torrent::set_max_connections(int limit)
|
||||
{
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
if (limit <= 0) limit = (std::numeric_limits<int>::max)();
|
||||
m_max_connections = limit;
|
||||
}
|
||||
|
||||
void torrent::set_peer_upload_limit(tcp::endpoint ip, int limit)
|
||||
{
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
peer_connection* p = connection_for(ip);
|
||||
if (p == 0) return;
|
||||
p->set_upload_limit(limit);
|
||||
|
@ -2500,7 +2500,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::set_peer_download_limit(tcp::endpoint ip, int limit)
|
||||
{
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
peer_connection* p = connection_for(ip);
|
||||
if (p == 0) return;
|
||||
p->set_download_limit(limit);
|
||||
|
@ -2508,7 +2508,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::set_upload_limit(int limit)
|
||||
{
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
if (limit <= 0) limit = (std::numeric_limits<int>::max)();
|
||||
if (limit < num_peers() * 10) limit = num_peers() * 10;
|
||||
m_bandwidth_limit[peer_connection::upload_channel].throttle(limit);
|
||||
|
@ -2523,7 +2523,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::set_download_limit(int limit)
|
||||
{
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
if (limit <= 0) limit = (std::numeric_limits<int>::max)();
|
||||
if (limit < num_peers() * 10) limit = num_peers() * 10;
|
||||
m_bandwidth_limit[peer_connection::download_channel].throttle(limit);
|
||||
|
@ -2567,7 +2567,7 @@ namespace libtorrent
|
|||
// files and flush all cached data
|
||||
if (m_owning_storage.get())
|
||||
{
|
||||
assert(m_storage);
|
||||
TORRENT_ASSERT(m_storage);
|
||||
m_storage->async_release_files(
|
||||
bind(&torrent::on_torrent_paused, shared_from_this(), _1, _2));
|
||||
}
|
||||
|
@ -2682,7 +2682,7 @@ namespace libtorrent
|
|||
|
||||
bool torrent::try_connect_peer()
|
||||
{
|
||||
assert(want_more_peers());
|
||||
TORRENT_ASSERT(want_more_peers());
|
||||
return m_policy->connect_one_peer();
|
||||
}
|
||||
|
||||
|
@ -2690,11 +2690,11 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(m_storage);
|
||||
assert(m_storage->refcount() > 0);
|
||||
assert(piece_index >= 0);
|
||||
assert(piece_index < m_torrent_file->num_pieces());
|
||||
assert(piece_index < (int)m_have_pieces.size());
|
||||
TORRENT_ASSERT(m_storage);
|
||||
TORRENT_ASSERT(m_storage->refcount() > 0);
|
||||
TORRENT_ASSERT(piece_index >= 0);
|
||||
TORRENT_ASSERT(piece_index < m_torrent_file->num_pieces());
|
||||
TORRENT_ASSERT(piece_index < (int)m_have_pieces.size());
|
||||
|
||||
m_storage->async_hash(piece_index, bind(&torrent::on_piece_verified
|
||||
, shared_from_this(), _1, _2, f));
|
||||
|
@ -2718,7 +2718,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::file_progress(std::vector<float>& fp) const
|
||||
{
|
||||
assert(valid_metadata());
|
||||
TORRENT_ASSERT(valid_metadata());
|
||||
|
||||
fp.clear();
|
||||
fp.resize(m_torrent_file->num_files(), 0.f);
|
||||
|
@ -2746,7 +2746,7 @@ namespace libtorrent
|
|||
ret.start = 0;
|
||||
size -= bytes_step;
|
||||
}
|
||||
assert(size == 0);
|
||||
TORRENT_ASSERT(size == 0);
|
||||
|
||||
fp[i] = static_cast<float>(done) / m_torrent_file->file_at(i).size;
|
||||
}
|
||||
|
@ -2756,7 +2756,7 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
assert(std::accumulate(
|
||||
TORRENT_ASSERT(std::accumulate(
|
||||
m_have_pieces.begin()
|
||||
, m_have_pieces.end()
|
||||
, 0) == m_num_pieces);
|
||||
|
@ -2852,7 +2852,7 @@ namespace libtorrent
|
|||
st.total_wanted -= filtered_pieces * m_torrent_file->piece_length();
|
||||
}
|
||||
|
||||
assert(st.total_wanted >= st.total_wanted_done);
|
||||
TORRENT_ASSERT(st.total_wanted >= st.total_wanted_done);
|
||||
|
||||
if (st.total_wanted == 0) st.progress = 1.f;
|
||||
else st.progress = st.total_wanted_done
|
||||
|
@ -2867,7 +2867,7 @@ namespace libtorrent
|
|||
}
|
||||
else if (is_seed())
|
||||
{
|
||||
assert(st.total_done == m_torrent_file->total_size());
|
||||
TORRENT_ASSERT(st.total_done == m_torrent_file->total_size());
|
||||
st.state = torrent_status::seeding;
|
||||
}
|
||||
else if (st.total_wanted_done == st.total_wanted)
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace libtorrent
|
|||
|
||||
void torrent_handle::check_invariant() const
|
||||
{
|
||||
assert((m_ses == 0 && m_chk == 0) || (m_ses != 0 && m_chk != 0));
|
||||
TORRENT_ASSERT((m_ses == 0 && m_chk == 0) || (m_ses != 0 && m_chk != 0));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -121,9 +121,9 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
assert(max_uploads >= 2 || max_uploads == -1);
|
||||
TORRENT_ASSERT(max_uploads >= 2 || max_uploads == -1);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -135,7 +135,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -147,9 +147,9 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
assert(max_connections >= 2 || max_connections == -1);
|
||||
TORRENT_ASSERT(max_connections >= 2 || max_connections == -1);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -159,10 +159,10 @@ namespace libtorrent
|
|||
void torrent_handle::set_peer_upload_limit(tcp::endpoint ip, int limit) const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -172,10 +172,10 @@ namespace libtorrent
|
|||
void torrent_handle::set_peer_download_limit(tcp::endpoint ip, int limit) const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -187,9 +187,9 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -201,7 +201,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -213,9 +213,9 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
assert(limit >= -1);
|
||||
TORRENT_ASSERT(limit >= -1);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -227,7 +227,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -240,7 +240,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -252,7 +252,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -264,7 +264,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -276,7 +276,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -288,7 +288,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -300,7 +300,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -313,7 +313,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -325,7 +325,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -355,7 +355,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -391,7 +391,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -403,7 +403,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -416,7 +416,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -428,7 +428,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -440,7 +440,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -452,7 +452,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -464,7 +464,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
std::vector<int> ret;
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
|
@ -478,7 +478,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -492,7 +492,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -504,7 +504,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -516,7 +516,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -528,7 +528,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
std::vector<bool> ret;
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
|
@ -542,7 +542,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -557,7 +557,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -569,7 +569,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -581,7 +581,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -593,7 +593,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -606,7 +606,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -618,7 +618,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -632,7 +632,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) return false;
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -653,7 +653,7 @@ namespace libtorrent
|
|||
|
||||
std::vector<int> piece_index;
|
||||
if (m_ses == 0) return entry();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l(m_ses->m_mutex);
|
||||
boost::shared_ptr<torrent> t = m_ses->find_torrent(m_info_hash).lock();
|
||||
|
@ -718,11 +718,11 @@ namespace libtorrent
|
|||
v |= (i->info[j*8+k].state == piece_picker::block_info::state_finished)
|
||||
? (1 << k) : 0;
|
||||
bitmask.insert(bitmask.end(), v);
|
||||
assert(bits == 8 || j == num_bitmask_bytes - 1);
|
||||
TORRENT_ASSERT(bits == 8 || j == num_bitmask_bytes - 1);
|
||||
}
|
||||
piece_struct["bitmask"] = bitmask;
|
||||
|
||||
assert(t->filesystem().slot_for_piece(i->index) >= 0);
|
||||
TORRENT_ASSERT(t->filesystem().slot_for_piece(i->index) >= 0);
|
||||
unsigned long adler
|
||||
= t->filesystem().piece_crc(
|
||||
t->filesystem().slot_for_piece(i->index)
|
||||
|
@ -781,7 +781,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -793,7 +793,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l(m_ses->m_mutex);
|
||||
boost::shared_ptr<torrent> t = m_ses->find_torrent(m_info_hash).lock();
|
||||
|
@ -822,7 +822,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l(m_ses->m_mutex);
|
||||
boost::shared_ptr<torrent> t = m_ses->find_torrent(m_info_hash).lock();
|
||||
|
@ -837,7 +837,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l(m_ses->m_mutex);
|
||||
boost::shared_ptr<torrent> t = m_ses->find_torrent(m_info_hash).lock();
|
||||
|
@ -851,9 +851,9 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
assert(ratio >= 0.f);
|
||||
TORRENT_ASSERT(ratio >= 0.f);
|
||||
if (ratio < 1.f && ratio > 0.f)
|
||||
ratio = 1.f;
|
||||
|
||||
|
@ -868,7 +868,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -880,7 +880,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l1(m_ses->m_mutex);
|
||||
mutex::scoped_lock l2(m_chk->m_mutex);
|
||||
|
@ -893,7 +893,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
v.clear();
|
||||
|
||||
|
@ -927,7 +927,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses == 0) throw_invalid_handle();
|
||||
assert(m_chk);
|
||||
TORRENT_ASSERT(m_chk);
|
||||
|
||||
session_impl::mutex_t::scoped_lock l(m_ses->m_mutex);
|
||||
boost::shared_ptr<torrent> t = m_ses->find_torrent(m_info_hash).lock();
|
||||
|
@ -981,7 +981,7 @@ namespace libtorrent
|
|||
if (pbp && pbp->piece_index == i->index && pbp->block_index == j)
|
||||
{
|
||||
bi.bytes_progress = pbp->bytes_downloaded;
|
||||
assert(bi.bytes_progress <= bi.block_size);
|
||||
TORRENT_ASSERT(bi.bytes_progress <= bi.block_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -208,7 +208,7 @@ namespace
|
|||
/*
|
||||
void remove_dir(fs::path& p)
|
||||
{
|
||||
assert(p.begin() != p.end());
|
||||
TORRENT_ASSERT(p.begin() != p.end());
|
||||
path tmp;
|
||||
for (path::iterator i = boost::next(p.begin()); i != p.end(); ++i)
|
||||
tmp /= *i;
|
||||
|
@ -311,12 +311,12 @@ namespace libtorrent
|
|||
{
|
||||
if (size & (1 << i))
|
||||
{
|
||||
assert((size & ~(1 << i)) == 0);
|
||||
TORRENT_ASSERT((size & ~(1 << i)) == 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
assert(!m_half_metadata);
|
||||
TORRENT_ASSERT(!m_half_metadata);
|
||||
m_piece_length = size;
|
||||
|
||||
m_num_pieces = static_cast<int>(
|
||||
|
@ -420,7 +420,7 @@ namespace libtorrent
|
|||
std::vector<char> info_section_buf;
|
||||
entry gen_info_section = create_info_metadata();
|
||||
bencode(std::back_inserter(info_section_buf), gen_info_section);
|
||||
assert(hasher(&info_section_buf[0], info_section_buf.size()).final()
|
||||
TORRENT_ASSERT(hasher(&info_section_buf[0], info_section_buf.size()).final()
|
||||
== m_info_hash);
|
||||
#endif
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ namespace libtorrent
|
|||
|
||||
void torrent_info::add_file(fs::path file, size_type size)
|
||||
{
|
||||
// assert(file.begin() != file.end());
|
||||
// TORRENT_ASSERT(file.begin() != file.end());
|
||||
|
||||
if (!file.has_branch_path())
|
||||
{
|
||||
|
@ -562,15 +562,15 @@ namespace libtorrent
|
|||
// path to the file (branch_path), which means that
|
||||
// all the other files need to be in the same top
|
||||
// directory as the first file.
|
||||
assert(m_files.empty());
|
||||
assert(!m_multifile);
|
||||
TORRENT_ASSERT(m_files.empty());
|
||||
TORRENT_ASSERT(!m_multifile);
|
||||
m_name = file.string();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if (!m_files.empty())
|
||||
assert(m_name == *file.begin());
|
||||
TORRENT_ASSERT(m_name == *file.begin());
|
||||
#endif
|
||||
m_multifile = true;
|
||||
m_name = *file.begin();
|
||||
|
@ -616,7 +616,7 @@ namespace libtorrent
|
|||
entry torrent_info::create_info_metadata() const
|
||||
{
|
||||
// you have to add files to the torrent first
|
||||
assert(!m_files.empty());
|
||||
TORRENT_ASSERT(!m_files.empty());
|
||||
|
||||
entry info(m_extra_info);
|
||||
|
||||
|
@ -644,8 +644,8 @@ namespace libtorrent
|
|||
fs::path const* file_path;
|
||||
if (i->orig_path) file_path = &(*i->orig_path);
|
||||
else file_path = &i->path;
|
||||
assert(file_path->has_branch_path());
|
||||
assert(*file_path->begin() == m_name);
|
||||
TORRENT_ASSERT(file_path->has_branch_path());
|
||||
TORRENT_ASSERT(*file_path->begin() == m_name);
|
||||
|
||||
for (fs::path::iterator j = boost::next(file_path->begin());
|
||||
j != file_path->end(); ++j)
|
||||
|
@ -672,7 +672,7 @@ namespace libtorrent
|
|||
|
||||
entry torrent_info::create_torrent() const
|
||||
{
|
||||
assert(m_piece_length > 0);
|
||||
TORRENT_ASSERT(m_piece_length > 0);
|
||||
|
||||
if (m_files.empty())
|
||||
{
|
||||
|
@ -760,14 +760,14 @@ namespace libtorrent
|
|||
|
||||
void torrent_info::set_hash(int index, const sha1_hash& h)
|
||||
{
|
||||
assert(index >= 0);
|
||||
assert(index < (int)m_piece_hash.size());
|
||||
TORRENT_ASSERT(index >= 0);
|
||||
TORRENT_ASSERT(index < (int)m_piece_hash.size());
|
||||
m_piece_hash[index] = h;
|
||||
}
|
||||
|
||||
void torrent_info::convert_file_names()
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
||||
void torrent_info::seed_free()
|
||||
|
@ -806,13 +806,13 @@ namespace libtorrent
|
|||
|
||||
size_type torrent_info::piece_size(int index) const
|
||||
{
|
||||
assert(index >= 0 && index < num_pieces());
|
||||
TORRENT_ASSERT(index >= 0 && index < num_pieces());
|
||||
if (index == num_pieces()-1)
|
||||
{
|
||||
size_type size = total_size()
|
||||
- (num_pieces() - 1) * piece_length();
|
||||
assert(size > 0);
|
||||
assert(size <= piece_length());
|
||||
TORRENT_ASSERT(size > 0);
|
||||
TORRENT_ASSERT(size <= piece_length());
|
||||
return size;
|
||||
}
|
||||
else
|
||||
|
@ -852,11 +852,11 @@ namespace libtorrent
|
|||
std::vector<file_slice> torrent_info::map_block(int piece, size_type offset
|
||||
, int size, bool storage) const
|
||||
{
|
||||
assert(num_files() > 0);
|
||||
TORRENT_ASSERT(num_files() > 0);
|
||||
std::vector<file_slice> ret;
|
||||
|
||||
size_type start = piece * (size_type)m_piece_length + offset;
|
||||
assert(start + size <= m_total_size);
|
||||
TORRENT_ASSERT(start + size <= m_total_size);
|
||||
|
||||
// find the file iterator and file offset
|
||||
// TODO: make a vector that can map piece -> file index in O(1)
|
||||
|
@ -866,7 +866,7 @@ namespace libtorrent
|
|||
int counter = 0;
|
||||
for (file_iter = begin_files(storage);; ++counter, ++file_iter)
|
||||
{
|
||||
assert(file_iter != end_files(storage));
|
||||
TORRENT_ASSERT(file_iter != end_files(storage));
|
||||
if (file_offset < file_iter->size)
|
||||
{
|
||||
file_slice f;
|
||||
|
@ -878,7 +878,7 @@ namespace libtorrent
|
|||
ret.push_back(f);
|
||||
}
|
||||
|
||||
assert(size >= 0);
|
||||
TORRENT_ASSERT(size >= 0);
|
||||
if (size <= 0) break;
|
||||
|
||||
file_offset -= file_iter->size;
|
||||
|
@ -889,8 +889,8 @@ namespace libtorrent
|
|||
peer_request torrent_info::map_file(int file_index, size_type file_offset
|
||||
, int size, bool storage) const
|
||||
{
|
||||
assert(file_index < num_files(storage));
|
||||
assert(file_index >= 0);
|
||||
TORRENT_ASSERT(file_index < num_files(storage));
|
||||
TORRENT_ASSERT(file_index >= 0);
|
||||
size_type offset = file_offset + file_at(file_index, storage).offset;
|
||||
|
||||
peer_request ret;
|
||||
|
|
|
@ -84,8 +84,8 @@ namespace libtorrent
|
|||
// returns -1 if gzip header is invalid or the header size in bytes
|
||||
int gzip_header(const char* buf, int size)
|
||||
{
|
||||
assert(buf != 0);
|
||||
assert(size > 0);
|
||||
TORRENT_ASSERT(buf != 0);
|
||||
TORRENT_ASSERT(size > 0);
|
||||
|
||||
const unsigned char* buffer = reinterpret_cast<const unsigned char*>(buf);
|
||||
const int total_size = size;
|
||||
|
@ -162,7 +162,7 @@ namespace libtorrent
|
|||
, request_callback* requester
|
||||
, int maximum_tracker_response_length)
|
||||
{
|
||||
assert(maximum_tracker_response_length > 0);
|
||||
TORRENT_ASSERT(maximum_tracker_response_length > 0);
|
||||
|
||||
int header_len = gzip_header(&buffer[0], (int)buffer.size());
|
||||
if (header_len < 0)
|
||||
|
@ -349,7 +349,7 @@ namespace libtorrent
|
|||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
||||
tracker_connection::tracker_connection(
|
||||
|
@ -490,11 +490,11 @@ namespace libtorrent
|
|||
, boost::weak_ptr<request_callback> c)
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
assert(req.num_want >= 0);
|
||||
TORRENT_ASSERT(req.num_want >= 0);
|
||||
if (req.event == tracker_request::stopped)
|
||||
req.num_want = 0;
|
||||
|
||||
assert(!m_abort || req.event == tracker_request::stopped);
|
||||
TORRENT_ASSERT(!m_abort || req.event == tracker_request::stopped);
|
||||
if (m_abort && req.event != tracker_request::stopped)
|
||||
return;
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace libtorrent
|
|||
!= bind_interface().is_v4(); ++target);
|
||||
if (target == end)
|
||||
{
|
||||
assert(target_address.address().is_v4() != bind_interface().is_v4());
|
||||
TORRENT_ASSERT(target_address.address().is_v4() != bind_interface().is_v4());
|
||||
if (cb)
|
||||
{
|
||||
std::string tracker_address_type = target_address.address().is_v4() ? "IPv4" : "IPv6";
|
||||
|
|
|
@ -222,7 +222,7 @@ try
|
|||
#ifndef NDEBUG
|
||||
catch (std::exception&)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -413,7 +413,7 @@ try
|
|||
#ifndef NDEBUG
|
||||
catch (std::exception&)
|
||||
{
|
||||
assert(false);
|
||||
TORRENT_ASSERT(false);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -476,8 +476,8 @@ void upnp::map_port(rootdevice& d, int i)
|
|||
return;
|
||||
}
|
||||
d.mapping[i].need_update = false;
|
||||
assert(!d.upnp_connection);
|
||||
assert(d.service_namespace);
|
||||
TORRENT_ASSERT(!d.upnp_connection);
|
||||
TORRENT_ASSERT(d.service_namespace);
|
||||
|
||||
d.upnp_connection.reset(new http_connection(m_io_service
|
||||
, m_cc, m_strand.wrap(bind(&upnp::on_upnp_map_response, self(), _1, _2
|
||||
|
|
|
@ -304,7 +304,7 @@ namespace libtorrent { namespace
|
|||
std::copy(pex_msg.begin(), pex_msg.end(), i.begin);
|
||||
i.begin += pex_msg.size();
|
||||
|
||||
assert(i.begin == i.end);
|
||||
TORRENT_ASSERT(i.begin == i.end);
|
||||
m_pc.setup_send();
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ namespace libtorrent { namespace
|
|||
std::copy(pex_msg.begin(), pex_msg.end(), i.begin);
|
||||
i.begin += pex_msg.size();
|
||||
|
||||
assert(i.begin == i.end);
|
||||
TORRENT_ASSERT(i.begin == i.end);
|
||||
m_pc.setup_send();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace libtorrent
|
|||
// we only want left-over bandwidth
|
||||
set_non_prioritized(true);
|
||||
shared_ptr<torrent> tor = t.lock();
|
||||
assert(tor);
|
||||
TORRENT_ASSERT(tor);
|
||||
int blocks_per_piece = tor->torrent_file().piece_length() / tor->block_size();
|
||||
|
||||
// we always prefer downloading 1 MB chunks
|
||||
|
@ -115,7 +115,7 @@ namespace libtorrent
|
|||
return boost::optional<piece_block_progress>();
|
||||
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
piece_block_progress ret;
|
||||
|
||||
|
@ -148,7 +148,7 @@ namespace libtorrent
|
|||
void web_peer_connection::on_connected()
|
||||
{
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
// this is always a seed
|
||||
incoming_bitfield(std::vector<bool>(
|
||||
|
@ -164,9 +164,9 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
assert(t->valid_metadata());
|
||||
TORRENT_ASSERT(t->valid_metadata());
|
||||
|
||||
bool single_file_request = false;
|
||||
if (!m_path.empty() && m_path[m_path.size() - 1] != '/')
|
||||
|
@ -288,7 +288,7 @@ namespace libtorrent
|
|||
request += "\r\nConnection: keep-alive";
|
||||
request += "\r\n\r\n";
|
||||
m_first_request = false;
|
||||
assert(f.file_index >= 0);
|
||||
TORRENT_ASSERT(f.file_index >= 0);
|
||||
m_file_requests.push_back(f.file_index);
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
boost::shared_ptr<torrent> t = associated_torrent().lock();
|
||||
assert(t);
|
||||
TORRENT_ASSERT(t);
|
||||
|
||||
incoming_piece_fragment();
|
||||
|
||||
|
@ -345,9 +345,9 @@ namespace libtorrent
|
|||
boost::tie(payload, protocol) = m_parser.incoming(recv_buffer);
|
||||
m_statistics.received_bytes(payload, protocol);
|
||||
|
||||
assert(recv_buffer.left() == 0 || *recv_buffer.begin == 'H');
|
||||
TORRENT_ASSERT(recv_buffer.left() == 0 || *recv_buffer.begin == 'H');
|
||||
|
||||
assert(recv_buffer.left() <= packet_size());
|
||||
TORRENT_ASSERT(recv_buffer.left() <= packet_size());
|
||||
|
||||
// this means the entire status line hasn't been received yet
|
||||
if (m_parser.status_code() == -1) break;
|
||||
|
@ -403,7 +403,7 @@ namespace libtorrent
|
|||
// add the redirected url and remove the current one
|
||||
if (!single_file_request)
|
||||
{
|
||||
assert(!m_file_requests.empty());
|
||||
TORRENT_ASSERT(!m_file_requests.empty());
|
||||
int file_index = m_file_requests.front();
|
||||
|
||||
torrent_info const& info = t->torrent_file();
|
||||
|
@ -493,7 +493,7 @@ namespace libtorrent
|
|||
// skip the http header and the blocks we've already read. The
|
||||
// http_body.begin is now in sync with the request at the front
|
||||
// of the request queue
|
||||
// assert(in_range.start - int(m_piece.size()) <= front_request.start);
|
||||
// TORRENT_ASSERT(in_range.start - int(m_piece.size()) <= front_request.start);
|
||||
|
||||
// the http response body consists of 3 parts
|
||||
// 1. the middle of a block or the ending of a block
|
||||
|
@ -520,14 +520,14 @@ namespace libtorrent
|
|||
int copy_size = (std::min)((std::min)(front_request.length - piece_size
|
||||
, recv_buffer.left()), int(range_end - range_start - m_received_body));
|
||||
m_piece.resize(piece_size + copy_size);
|
||||
assert(copy_size > 0);
|
||||
TORRENT_ASSERT(copy_size > 0);
|
||||
std::memcpy(&m_piece[0] + piece_size, recv_buffer.begin, copy_size);
|
||||
assert(int(m_piece.size()) <= front_request.length);
|
||||
TORRENT_ASSERT(int(m_piece.size()) <= front_request.length);
|
||||
recv_buffer.begin += copy_size;
|
||||
m_received_body += copy_size;
|
||||
m_body_start += copy_size;
|
||||
assert(m_received_body <= range_end - range_start);
|
||||
assert(int(m_piece.size()) <= front_request.length);
|
||||
TORRENT_ASSERT(m_received_body <= range_end - range_start);
|
||||
TORRENT_ASSERT(int(m_piece.size()) <= front_request.length);
|
||||
if (int(m_piece.size()) == front_request.length)
|
||||
{
|
||||
// each call to incoming_piece() may result in us becoming
|
||||
|
@ -541,9 +541,9 @@ namespace libtorrent
|
|||
cut_receive_buffer(m_body_start, t->block_size() + 1024);
|
||||
m_body_start = 0;
|
||||
recv_buffer = receive_buffer();
|
||||
assert(m_received_body <= range_end - range_start);
|
||||
TORRENT_ASSERT(m_received_body <= range_end - range_start);
|
||||
m_piece.clear();
|
||||
assert(m_piece.empty());
|
||||
TORRENT_ASSERT(m_piece.empty());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -554,13 +554,13 @@ namespace libtorrent
|
|||
{
|
||||
peer_request r = m_requests.front();
|
||||
m_requests.pop_front();
|
||||
assert(recv_buffer.left() >= r.length);
|
||||
TORRENT_ASSERT(recv_buffer.left() >= r.length);
|
||||
|
||||
incoming_piece(r, recv_buffer.begin);
|
||||
if (associated_torrent().expired()) return;
|
||||
m_received_body += r.length;
|
||||
assert(receive_buffer().begin + m_body_start == recv_buffer.begin);
|
||||
assert(m_received_body <= range_end - range_start);
|
||||
TORRENT_ASSERT(receive_buffer().begin + m_body_start == recv_buffer.begin);
|
||||
TORRENT_ASSERT(m_received_body <= range_end - range_start);
|
||||
cut_receive_buffer(r.length + m_body_start, t->block_size() + 1024);
|
||||
m_body_start = 0;
|
||||
recv_buffer = receive_buffer();
|
||||
|
@ -577,7 +577,7 @@ namespace libtorrent
|
|||
int piece_size = int(m_piece.size());
|
||||
int copy_size = (std::min)((std::min)(m_requests.front().length - piece_size
|
||||
, recv_buffer.left()), int(range_end - range_start - m_received_body));
|
||||
assert(copy_size >= 0);
|
||||
TORRENT_ASSERT(copy_size >= 0);
|
||||
if (copy_size > 0)
|
||||
{
|
||||
m_piece.resize(piece_size + copy_size);
|
||||
|
@ -586,11 +586,11 @@ namespace libtorrent
|
|||
m_received_body += copy_size;
|
||||
m_body_start += copy_size;
|
||||
}
|
||||
assert(m_received_body == range_end - range_start);
|
||||
TORRENT_ASSERT(m_received_body == range_end - range_start);
|
||||
}
|
||||
}
|
||||
|
||||
assert(m_received_body <= range_end - range_start);
|
||||
TORRENT_ASSERT(m_received_body <= range_end - range_start);
|
||||
if (m_received_body == range_end - range_start)
|
||||
{
|
||||
cut_receive_buffer(recv_buffer.begin - receive_buffer().begin
|
||||
|
@ -642,7 +642,7 @@ namespace libtorrent
|
|||
void web_peer_connection::check_invariant() const
|
||||
{
|
||||
/*
|
||||
assert(m_num_pieces == std::count(
|
||||
TORRENT_ASSERT(m_num_pieces == std::count(
|
||||
m_have_piece.begin()
|
||||
, m_have_piece.end()
|
||||
, true));
|
||||
|
|
Loading…
Reference in New Issue