*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-05-10 06:12:29 +00:00
parent 6f818ec7c3
commit 22e2f8a164
7 changed files with 29 additions and 35 deletions

View File

@ -243,8 +243,8 @@ int main(int argc, char* argv[])
std::vector<torrent_handle> handles; std::vector<torrent_handle> handles;
session ses(fingerprint("LT", 0, 1, 0, 0)); session ses(fingerprint("LT", 0, 1, 0, 0));
ses.listen_on(std::make_pair(6881, 6889)); ses.listen_on(std::make_pair(100, 110));
// ses.set_upload_rate_limit(100000); ses.set_upload_rate_limit(50000);
// ses.set_download_rate_limit(50000); // ses.set_download_rate_limit(50000);
ses.set_http_settings(settings); ses.set_http_settings(settings);
ses.set_severity_level(alert::debug); ses.set_severity_level(alert::debug);
@ -277,7 +277,7 @@ int main(int argc, char* argv[])
handles.push_back(ses.add_torrent(t, save_path, resume_data)); handles.push_back(ses.add_torrent(t, save_path, resume_data));
handles.back().set_max_connections(60); handles.back().set_max_connections(60);
handles.back().set_max_uploads(-1); handles.back().set_max_uploads(7);
handles.back().set_ratio(1.02f); handles.back().set_ratio(1.02f);
} }
catch (std::exception& e) catch (std::exception& e)

View File

@ -121,7 +121,7 @@ namespace libtorrent
#ifndef NDEBUG #ifndef NDEBUG
bool has_connection(const peer_connection* p); bool has_connection(const peer_connection* p);
void check_invariant(); void check_invariant() const;
#endif #endif
struct peer struct peer

View File

@ -177,9 +177,18 @@ namespace libtorrent
else if (std::equal(f->id, f->id+2, "MT")) else if (std::equal(f->id, f->id+2, "MT"))
identity << "Moonlight Torrent "; identity << "Moonlight Torrent ";
// Torrent Storm
else if (std::equal(f->id, f->id+2, "TS")) else if (std::equal(f->id, f->id+2, "TS"))
identity << "TorrentStorm "; identity << "TorrentStorm ";
// SwarmScope
else if (std::equal(f->id, f->id+2, "SS"))
identity << "SwarmScope ";
// XanTorrent
else if (std::equal(f->id, f->id+2, "XT"))
identity << "XanTorrent ";
// unknown client // unknown client
else else
identity << std::string(f->id, f->id+2) << " "; identity << std::string(f->id, f->id+2) << " ";
@ -207,6 +216,10 @@ namespace libtorrent
else if (std::equal(f->id, f->id+1, "U")) else if (std::equal(f->id, f->id+1, "U"))
identity << "UPnP "; identity << "UPnP ";
// BitTornado
else if (std::equal(f->id, f->id+1, "T"))
identity << "BitTornado ";
// unknown client // unknown client
else else
identity << std::string(f->id, f->id+1) << " "; identity << std::string(f->id, f->id+1) << " ";

View File

@ -653,8 +653,7 @@ namespace libtorrent
while (m_num_unchoked > m_max_uploads) while (m_num_unchoked > m_max_uploads)
{ {
peer* p = find_seed_choke_candidate(); peer* p = find_seed_choke_candidate();
assert(p != 0);
if (p == 0) break;
p->connection->send_choke(); p->connection->send_choke();
--m_num_unchoked; --m_num_unchoked;
@ -666,6 +665,9 @@ namespace libtorrent
{ {
if (!seed_unchoke_one_peer()) break; if (!seed_unchoke_one_peer()) break;
} }
#ifndef NDEBUG
check_invariant();
#endif
} }
// ---------------------------- // ----------------------------
@ -720,7 +722,6 @@ namespace libtorrent
// unchoked peers // unchoked peers
while (m_num_unchoked < m_max_uploads && unchoke_one_peer()); while (m_num_unchoked < m_max_uploads && unchoke_one_peer());
} }
#ifndef NDEBUG #ifndef NDEBUG
check_invariant(); check_invariant();
#endif #endif
@ -815,7 +816,7 @@ namespace libtorrent
using namespace boost::posix_time; using namespace boost::posix_time;
using namespace boost::gregorian; using namespace boost::gregorian;
// we don't have ny info about this peer. // we don't have any info about this peer.
// add a new entry // add a new entry
peer p(remote, peer::connectable); peer p(remote, peer::connectable);
m_peers.push_back(p); m_peers.push_back(p);
@ -1087,11 +1088,11 @@ namespace libtorrent
, match_peer_ip(c->get_socket()->sender())) != m_peers.end(); , match_peer_ip(c->get_socket()->sender())) != m_peers.end();
} }
void policy::check_invariant() void policy::check_invariant() const
{ {
assert(m_max_uploads >= 2); assert(m_max_uploads >= 2);
int actual_unchoked = 0; int actual_unchoked = 0;
for (std::vector<peer>::iterator i = m_peers.begin(); for (std::vector<peer>::const_iterator i = m_peers.begin();
i != m_peers.end(); i != m_peers.end();
++i) ++i)
{ {

View File

@ -974,7 +974,7 @@ namespace libtorrent
assert(bytes_per_second > 0 || bytes_per_second == -1); assert(bytes_per_second > 0 || bytes_per_second == -1);
boost::mutex::scoped_lock l(m_impl.m_mutex); boost::mutex::scoped_lock l(m_impl.m_mutex);
m_impl.m_upload_rate = bytes_per_second; m_impl.m_upload_rate = bytes_per_second;
if (m_impl.m_upload_rate != -1 || !m_impl.m_connections.empty()) if (m_impl.m_upload_rate != -1/* || !m_impl.m_connections.empty()*/)
return; return;
for (detail::session_impl::connection_map::iterator i for (detail::session_impl::connection_map::iterator i
@ -990,7 +990,7 @@ namespace libtorrent
assert(bytes_per_second > 0 || bytes_per_second == -1); assert(bytes_per_second > 0 || bytes_per_second == -1);
boost::mutex::scoped_lock l(m_impl.m_mutex); boost::mutex::scoped_lock l(m_impl.m_mutex);
m_impl.m_download_rate = bytes_per_second; m_impl.m_download_rate = bytes_per_second;
if (m_impl.m_download_rate != -1 || !m_impl.m_connections.empty()) if (m_impl.m_download_rate != -1/* || !m_impl.m_connections.empty()*/)
return; return;
for (detail::session_impl::connection_map::iterator i for (detail::session_impl::connection_map::iterator i

View File

@ -1415,12 +1415,11 @@ namespace libtorrent
m_slot_to_piece[pos] = pos; m_slot_to_piece[pos] = pos;
m_piece_to_slot[pos] = pos; m_piece_to_slot[pos] = pos;
} }
m_unallocated_slots.erase(m_unallocated_slots.begin());
m_slot_to_piece[new_free_slot] = unassigned;
m_free_slots.push_back(new_free_slot);
m_storage.write(&zeros[0], pos, 0, static_cast<int>(m_info.piece_size(pos))); m_storage.write(&zeros[0], pos, 0, static_cast<int>(m_info.piece_size(pos)));
m_free_slots.push_back(new_free_slot);
m_slot_to_piece[new_free_slot] = unassigned;
m_unallocated_slots.erase(m_unallocated_slots.begin());
} }
assert(m_free_slots.size() > 0); assert(m_free_slots.size() > 0);

View File

@ -243,25 +243,6 @@ namespace libtorrent
m_got_tracker_response = true; m_got_tracker_response = true;
} }
/*
bool torrent::has_peer(const peer_id& id) const
{
assert(std::count_if(m_connections.begin()
, m_connections.end()
, peer_by_id(id)) <= 1);
// pretend that we are connected to
// ourself to avoid real connections
// to ourself
if (id == m_ses.m_peer_id) return true;
return std::find_if(
m_connections.begin()
, m_connections.end()
, peer_by_id(id))
!= m_connections.end();
}
*/
size_type torrent::bytes_left() const size_type torrent::bytes_left() const
{ {