forked from premiere/premiere-libtorrent
*** empty log message ***
This commit is contained in:
parent
bb36fa8e24
commit
0634e778e9
|
@ -123,7 +123,7 @@ namespace libtorrent
|
|||
|
||||
struct checker_impl: boost::noncopyable
|
||||
{
|
||||
checker_impl(session_impl* s): m_ses(s), m_abort(false) {}
|
||||
checker_impl(session_impl* s): m_ses(s), m_abort(false) { assert(s); }
|
||||
void operator()();
|
||||
piece_checker_data* find_torrent(const sha1_hash& info_hash);
|
||||
|
||||
|
@ -208,7 +208,7 @@ namespace libtorrent
|
|||
void purge_connections();
|
||||
|
||||
#ifndef NDEBUG
|
||||
void assert_invariant(int marker = -1);
|
||||
void assert_invariant(const char *place);
|
||||
boost::shared_ptr<logger> create_log(std::string name);
|
||||
boost::shared_ptr<logger> m_logger;
|
||||
#endif
|
||||
|
|
|
@ -80,9 +80,9 @@ namespace libtorrent
|
|||
bool operator<(const address& a) const
|
||||
{ if (ip() == a.ip()) return port() < a.port(); else return ip() < a.ip(); }
|
||||
bool operator!=(const address& a) const
|
||||
{ return (ip() != a.ip()) || port() != a.port(); }
|
||||
{ return ip() != a.ip() || port() != a.port(); }
|
||||
bool operator==(const address& a) const
|
||||
{ return (ip() == a.ip()) && port() == a.port(); }
|
||||
{ return ip() == a.ip() && port() == a.port(); }
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -104,17 +104,17 @@ namespace libtorrent
|
|||
void second_tick();
|
||||
|
||||
// only counts the payload data!
|
||||
float upload_rate() const { return m_mean_upload_per_second; }
|
||||
float download_rate() const { return m_mean_download_per_second; }
|
||||
float upload_rate() const { assert(m_mean_upload_per_second>=0.0f); return m_mean_upload_per_second; }
|
||||
float download_rate() const { assert(m_mean_download_per_second>=0.0f); return m_mean_download_per_second; }
|
||||
|
||||
float down_peak() const { return m_peak_downloaded_per_second; }
|
||||
float up_peak() const { return m_peak_uploaded_per_second; }
|
||||
|
||||
size_type total_payload_upload() const { return m_total_upload_payload; }
|
||||
size_type total_payload_download() const { return m_total_download_payload; }
|
||||
size_type total_payload_upload() const { assert(m_total_upload_payload>=0); return m_total_upload_payload; }
|
||||
size_type total_payload_download() const { assert(m_total_download_payload>=0); return m_total_download_payload; }
|
||||
|
||||
size_type total_protocol_upload() const { return m_total_upload_protocol; }
|
||||
size_type total_protocol_download() const { return m_total_download_protocol; }
|
||||
size_type total_protocol_upload() const { assert(m_total_upload_protocol>=0); return m_total_upload_protocol; }
|
||||
size_type total_protocol_download() const { assert(m_total_download_protocol>=0); return m_total_download_protocol; }
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -119,15 +119,15 @@ namespace libtorrent
|
|||
const torrent_info& torrent_file() const
|
||||
{ return m_torrent_file; }
|
||||
|
||||
policy& get_policy() { return *m_policy; }
|
||||
policy& get_policy() { assert(m_policy); return *m_policy; }
|
||||
|
||||
piece_manager& filesystem() { return m_storage; }
|
||||
|
||||
void set_ratio(float ratio)
|
||||
{ m_ratio = ratio; }
|
||||
{ assert(ratio>=0.0f); m_ratio = ratio; }
|
||||
|
||||
float ratio() const
|
||||
{ return m_ratio; }
|
||||
{ assert(m_ratio>=0.0f); return m_ratio; }
|
||||
|
||||
// --------------------------------------------
|
||||
// PEER MANAGEMENT
|
||||
|
@ -187,8 +187,9 @@ namespace libtorrent
|
|||
// PIECE MANAGEMENT
|
||||
|
||||
// returns true if we have downloaded the given piece
|
||||
bool have_piece(unsigned int index) const
|
||||
{ return m_have_pieces[index]; }
|
||||
bool have_piece(int index) const
|
||||
{ assert(index>=0 && (unsigned)index<m_have_pieces.size());
|
||||
return m_have_pieces[index]; }
|
||||
|
||||
const std::vector<bool>& pieces() const
|
||||
{ return m_have_pieces; }
|
||||
|
@ -196,13 +197,14 @@ namespace libtorrent
|
|||
// when we get a have- or bitfield- messages, this is called for every
|
||||
// piece a peer has gained.
|
||||
void peer_has(int index)
|
||||
{ m_picker.inc_refcount(index); }
|
||||
{ assert(index>=0 && (unsigned)index<m_have_pieces.size());
|
||||
m_picker.inc_refcount(index); }
|
||||
|
||||
// when peer disconnects, this is called for every piece it had
|
||||
void peer_lost(int index)
|
||||
{ m_picker.dec_refcount(index); }
|
||||
|
||||
int block_size() const { return m_block_size; }
|
||||
int block_size() const { 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
|
||||
|
@ -231,7 +233,7 @@ namespace libtorrent
|
|||
|
||||
void set_priority(float p)
|
||||
{
|
||||
assert(p >= 0.f && p <= 0.f);
|
||||
assert(p >= 0.f && p <= 1.f);
|
||||
m_priority = p;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,9 +116,10 @@ namespace
|
|||
{
|
||||
using namespace libtorrent;
|
||||
|
||||
assert(upload_limit > 0 || upload_limit==-1);
|
||||
|
||||
if (connections.empty()) return;
|
||||
|
||||
assert(upload_limit != 0);
|
||||
|
||||
if (upload_limit == -1)
|
||||
{
|
||||
|
@ -169,7 +170,7 @@ namespace
|
|||
// Sum all peer_connections' quota limit to get the total quota limit.
|
||||
|
||||
int sum_total_of_quota_limits=0;
|
||||
for(int i=0;i<peer_info.size();i++)
|
||||
for(int i=0;(unsigned)i<peer_info.size();i++)
|
||||
{
|
||||
int quota_limit=peer_info[i].quota_limit;
|
||||
if(quota_limit==-1)
|
||||
|
@ -197,7 +198,7 @@ namespace
|
|||
{
|
||||
assert(quota_left_to_distribute>0);
|
||||
|
||||
for(int i=0;i<peer_info.size();i++)
|
||||
for(int i=0;(unsigned)i<peer_info.size();i++)
|
||||
{
|
||||
// Traverse the peer list from slowest connection to fastest.
|
||||
|
||||
|
@ -223,7 +224,7 @@ namespace
|
|||
|
||||
// Finally, inform the peers of how much quota they get.
|
||||
|
||||
for(int i=0;i<peer_info.size();i++)
|
||||
for(int i=0;(unsigned)i<peer_info.size();i++)
|
||||
peer_info[i].p->set_send_quota(peer_info[i].allocated_quota);
|
||||
}
|
||||
|
||||
|
@ -349,6 +350,7 @@ namespace libtorrent
|
|||
, m_upload_rate(-1)
|
||||
, m_incoming_connection(false)
|
||||
{
|
||||
assert(listen_port>0);
|
||||
|
||||
// ---- generate a peer id ----
|
||||
|
||||
|
@ -431,7 +433,7 @@ namespace libtorrent
|
|||
{
|
||||
|
||||
#ifndef NDEBUG
|
||||
assert_invariant(0);
|
||||
assert_invariant("loops_per_second++");
|
||||
loops_per_second++;
|
||||
#endif
|
||||
|
||||
|
@ -472,7 +474,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
assert_invariant();
|
||||
assert_invariant("before SEND SOCKETS");
|
||||
#endif
|
||||
|
||||
// ************************
|
||||
|
@ -520,7 +522,7 @@ namespace libtorrent
|
|||
purge_connections();
|
||||
|
||||
#ifndef NDEBUG
|
||||
assert_invariant();
|
||||
assert_invariant("after SEND SOCKETS");
|
||||
#endif
|
||||
// ************************
|
||||
// RECEIVE SOCKETS
|
||||
|
@ -584,7 +586,7 @@ namespace libtorrent
|
|||
}
|
||||
purge_connections();
|
||||
#ifndef NDEBUG
|
||||
assert_invariant();
|
||||
assert_invariant("after RECEIVE SOCKETS");
|
||||
#endif
|
||||
|
||||
// ************************
|
||||
|
@ -616,7 +618,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
assert_invariant();
|
||||
assert_invariant("after ERROR SOCKETS");
|
||||
#endif
|
||||
|
||||
boost::posix_time::time_duration d = boost::posix_time::second_clock::local_time() - timer;
|
||||
|
@ -744,10 +746,10 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
void session_impl::assert_invariant(int marker)
|
||||
void session_impl::assert_invariant(const char *place)
|
||||
{
|
||||
static int place = 0;
|
||||
if (marker != -1) place = 0;
|
||||
assert(place);
|
||||
|
||||
for (connection_map::iterator i = m_connections.begin();
|
||||
i != m_connections.end();
|
||||
++i)
|
||||
|
@ -772,7 +774,6 @@ namespace libtorrent
|
|||
->get_policy().has_connection(boost::get_pointer(i->second)));
|
||||
}
|
||||
}
|
||||
place++;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -985,7 +986,7 @@ namespace libtorrent
|
|||
|
||||
// read piece map
|
||||
const entry::list_type& slots = rd.dict()["slots"].list();
|
||||
if (slots.size() > info.num_pieces())
|
||||
if ((int)slots.size() > info.num_pieces())
|
||||
return;
|
||||
|
||||
std::vector<int> tmp_pieces;
|
||||
|
|
|
@ -67,7 +67,10 @@ namespace {
|
|||
lazy_hash(const char* data_, std::size_t size_)
|
||||
: data(data_)
|
||||
, size(size_)
|
||||
{}
|
||||
{
|
||||
assert(data_);
|
||||
assert(size_>0);
|
||||
}
|
||||
|
||||
const libtorrent::sha1_hash& get() const
|
||||
{
|
||||
|
@ -156,7 +159,7 @@ namespace libtorrent
|
|||
{
|
||||
thread_safe_storage(std::size_t n)
|
||||
: slots(n, false)
|
||||
{}
|
||||
{ assert(n>=0); }
|
||||
|
||||
boost::mutex mutex;
|
||||
boost::condition condition;
|
||||
|
@ -169,6 +172,7 @@ namespace libtorrent
|
|||
: storage_(s)
|
||||
, slot(slot_)
|
||||
{
|
||||
assert(slot_>=0 && (unsigned)slot_ < s.slots.size());
|
||||
boost::mutex::scoped_lock lock(storage_.mutex);
|
||||
|
||||
while (storage_.slots[slot])
|
||||
|
@ -221,6 +225,8 @@ namespace libtorrent
|
|||
, size_type offset
|
||||
, size_type size)
|
||||
{
|
||||
assert(buf);
|
||||
assert(slot >= 0 && slot < m_pimpl->info.num_pieces());
|
||||
assert(offset >= 0);
|
||||
assert(offset < m_pimpl->info.piece_size(slot));
|
||||
assert(size > 0);
|
||||
|
@ -310,6 +316,9 @@ namespace libtorrent
|
|||
|
||||
void storage::write(const char* buf, int slot, size_type offset, size_type size)
|
||||
{
|
||||
assert(buf);
|
||||
assert(slot >= 0 && slot < m_pimpl->info.num_pieces());
|
||||
assert(offset >= 0);
|
||||
assert(size > 0);
|
||||
|
||||
slot_lock lock(*m_pimpl, slot);
|
||||
|
@ -600,6 +609,9 @@ namespace libtorrent
|
|||
, int block_size
|
||||
, const std::bitset<256>& bitmask)
|
||||
{
|
||||
assert(slot_index >= 0 && slot_index < m_info.num_pieces());
|
||||
assert(block_size>0);
|
||||
|
||||
adler32_crc crc;
|
||||
std::vector<char> buf(block_size);
|
||||
int num_blocks = m_info.piece_size(slot_index) / block_size;
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace
|
|||
/*
|
||||
struct find_peer_by_id
|
||||
{
|
||||
find_peer_by_id(const peer_id& i, const torrent* t): id(i), tor(t) {}
|
||||
find_peer_by_id(const peer_id& i, const torrent* t): id(i), tor(t) { assert(t); }
|
||||
|
||||
bool operator()(const detail::session_impl::connection_map::value_type& c) const
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ namespace
|
|||
*/
|
||||
struct find_peer_by_ip
|
||||
{
|
||||
find_peer_by_ip(const address& a, const torrent* t): ip(a), tor(t) {}
|
||||
find_peer_by_ip(const address& a, const torrent* t): ip(a), tor(t) { assert(t); }
|
||||
|
||||
bool operator()(const detail::session_impl::connection_map::value_type& c) const
|
||||
{
|
||||
|
@ -192,6 +192,8 @@ namespace libtorrent
|
|||
|
||||
std::string escape_string(const char* str, int len)
|
||||
{
|
||||
assert(str);
|
||||
assert(len>=0);
|
||||
// http://www.ietf.org/rfc/rfc2396.txt
|
||||
// section 2.3
|
||||
static const char unreserved_chars[] = "-_.!~*'()";
|
||||
|
@ -255,6 +257,7 @@ namespace libtorrent
|
|||
std::vector<peer_entry>& peer_list
|
||||
, int interval)
|
||||
{
|
||||
assert(interval>0);
|
||||
m_last_working_tracker
|
||||
= m_torrent_file.prioritize_tracker(m_currently_trying_tracker);
|
||||
m_next_request = boost::posix_time::second_clock::local_time()
|
||||
|
@ -391,6 +394,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::piece_failed(int index)
|
||||
{
|
||||
assert(index >= 0 && index < m_torrent_file.num_pieces());
|
||||
if (m_ses.m_alerts.should_post(alert::info))
|
||||
{
|
||||
std::stringstream s;
|
||||
|
@ -436,6 +440,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::announce_piece(int index)
|
||||
{
|
||||
assert(index >= 0 && index < m_torrent_file.num_pieces());
|
||||
std::vector<address> downloaders;
|
||||
m_picker.get_downloaders(downloaders, index);
|
||||
|
||||
|
@ -457,6 +462,8 @@ namespace libtorrent
|
|||
|
||||
tracker_request torrent::generate_tracker_request(int port)
|
||||
{
|
||||
assert(port>0);
|
||||
assert((unsigned short)port == port);
|
||||
m_duration = 1800;
|
||||
m_next_request = boost::posix_time::second_clock::local_time() + boost::posix_time::seconds(m_duration);
|
||||
|
||||
|
@ -474,6 +481,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::remove_peer(peer_connection* p)
|
||||
{
|
||||
assert(p);
|
||||
peer_iterator i = m_connections.find(p->get_socket()->sender());
|
||||
assert(i != m_connections.end());
|
||||
|
||||
|
@ -544,6 +552,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::attach_peer(peer_connection* p)
|
||||
{
|
||||
assert(p);
|
||||
assert(m_connections.find(p->get_socket()->sender()) == m_connections.end());
|
||||
assert(!p->is_local());
|
||||
|
||||
|
@ -670,6 +679,7 @@ namespace libtorrent
|
|||
|
||||
bool torrent::verify_piece(int piece_index)
|
||||
{
|
||||
assert(piece_index >= 0 && piece_index < m_torrent_file.num_pieces());
|
||||
size_type size = m_torrent_file.piece_size(piece_index);
|
||||
std::vector<char> buffer(size);
|
||||
assert(size > 0);
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace libtorrent
|
|||
|
||||
void torrent_handle::set_max_uploads(int max_uploads)
|
||||
{
|
||||
assert(max_uploads>=2 || max_uploads==-1);
|
||||
if (m_ses == 0) throw invalid_handle();
|
||||
|
||||
{
|
||||
|
@ -94,6 +95,7 @@ namespace libtorrent
|
|||
|
||||
void torrent_handle::set_max_connections(int max_connections)
|
||||
{
|
||||
assert(max_connections>=2 || max_connections==-1);
|
||||
if (m_ses == 0) throw invalid_handle();
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue