*** empty log message ***
This commit is contained in:
@@ -238,6 +238,12 @@ namespace libtorrent
|
|||||||
const peer_id& get_peer_id() const { return m_peer_id; }
|
const peer_id& get_peer_id() const { return m_peer_id; }
|
||||||
const std::vector<bool>& get_bitfield() const { return m_have_piece; }
|
const std::vector<bool>& get_bitfield() const { return m_have_piece; }
|
||||||
|
|
||||||
|
// this will cause this peer_connection to be disconnected.
|
||||||
|
// what it does is that it puts a reference to it in
|
||||||
|
// m_ses.m_disconnect_peer list, which will be scanned in the
|
||||||
|
// mainloop to disconnect peers.
|
||||||
|
void disconnect();
|
||||||
|
|
||||||
// sets the number of bytes this peer
|
// sets the number of bytes this peer
|
||||||
// is allowed to send until it should
|
// is allowed to send until it should
|
||||||
// stop sending. When it stops sending
|
// stop sending. When it stops sending
|
||||||
|
@@ -156,8 +156,18 @@ namespace libtorrent
|
|||||||
|
|
||||||
tracker_manager m_tracker_manager;
|
tracker_manager m_tracker_manager;
|
||||||
std::map<sha1_hash, boost::shared_ptr<torrent> > m_torrents;
|
std::map<sha1_hash, boost::shared_ptr<torrent> > m_torrents;
|
||||||
|
|
||||||
|
// this maps sockets to their peer_connection
|
||||||
|
// object. It is the complete list of all connected
|
||||||
|
// peers.
|
||||||
connection_map m_connections;
|
connection_map m_connections;
|
||||||
|
|
||||||
|
// this is a list of iterators into the m_connections map
|
||||||
|
// that should be disconnected as soon as possible.
|
||||||
|
// It is used to delay disconnections to avoid troubles
|
||||||
|
// in loops that iterate over them.
|
||||||
|
std::vector<connection_map::iterator> m_disconnect_peer;
|
||||||
|
|
||||||
// the peer id that is generated at the start of each torrent
|
// the peer id that is generated at the start of each torrent
|
||||||
peer_id m_peer_id;
|
peer_id m_peer_id;
|
||||||
|
|
||||||
@@ -191,6 +201,10 @@ namespace libtorrent
|
|||||||
// NAT or not.
|
// NAT or not.
|
||||||
bool m_incoming_connection;
|
bool m_incoming_connection;
|
||||||
|
|
||||||
|
// does the actual disconnections
|
||||||
|
// that are queued up in m_disconnect_peer
|
||||||
|
void purge_connections();
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void assert_invariant(int marker = -1);
|
void assert_invariant(int marker = -1);
|
||||||
boost::shared_ptr<logger> create_log(std::string name);
|
boost::shared_ptr<logger> create_log(std::string name);
|
||||||
|
@@ -210,6 +210,7 @@ namespace libtorrent
|
|||||||
void announce_piece(int index);
|
void announce_piece(int index);
|
||||||
|
|
||||||
void close_all_connections();
|
void close_all_connections();
|
||||||
|
void disconnect_seeds();
|
||||||
|
|
||||||
piece_picker& picker() { return m_picker; }
|
piece_picker& picker() { return m_picker; }
|
||||||
|
|
||||||
|
@@ -43,6 +43,8 @@ namespace
|
|||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
int err = GetLastError();
|
int err = GetLastError();
|
||||||
|
// TODO: can this be done in an exception safe AND
|
||||||
|
// buffer overrun-safe way?
|
||||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, err, 0, buffer, 0, 0);
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, err, 0, buffer, 0, 0);
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << thrower << ": " << buffer;
|
s << thrower << ": " << buffer;
|
||||||
|
@@ -693,8 +693,6 @@ namespace libtorrent
|
|||||||
if (verified)
|
if (verified)
|
||||||
{
|
{
|
||||||
m_torrent->announce_piece(p.piece);
|
m_torrent->announce_piece(p.piece);
|
||||||
// TODO: if we bacame a seed, disconnect
|
|
||||||
// from all seeds
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -711,6 +709,8 @@ namespace libtorrent
|
|||||||
m_torrent->get_handle()
|
m_torrent->get_handle()
|
||||||
, "torrent is finished downloading"));
|
, "torrent is finished downloading"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_torrent->disconnect_seeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -866,8 +866,13 @@ namespace libtorrent
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void peer_connection::disconnect()
|
||||||
|
{
|
||||||
|
detail::session_impl::connection_map::iterator i = m_ses.m_connections.find(m_socket);
|
||||||
|
assert(i != m_ses.m_connections.end());
|
||||||
|
assert(std::find(m_ses.m_disconnect_peer.begin(), m_ses.m_disconnect_peer.end(), i) == m_ses.m_disconnect_peer.end());
|
||||||
|
m_ses.m_disconnect_peer.push_back(i);
|
||||||
|
}
|
||||||
|
|
||||||
bool peer_connection::dispatch_message(int received)
|
bool peer_connection::dispatch_message(int received)
|
||||||
{
|
{
|
||||||
|
@@ -372,6 +372,14 @@ namespace libtorrent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void session_impl::purge_connections()
|
||||||
|
{
|
||||||
|
while (!m_disconnect_peer.empty())
|
||||||
|
{
|
||||||
|
m_connections.erase(m_disconnect_peer.back());
|
||||||
|
m_disconnect_peer.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void session_impl::operator()()
|
void session_impl::operator()()
|
||||||
{
|
{
|
||||||
@@ -501,6 +509,7 @@ namespace libtorrent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
purge_connections();
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
assert_invariant();
|
assert_invariant();
|
||||||
@@ -568,7 +577,7 @@ namespace libtorrent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
purge_connections();
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
assert_invariant();
|
assert_invariant();
|
||||||
#endif
|
#endif
|
||||||
@@ -658,6 +667,8 @@ namespace libtorrent
|
|||||||
i->second->second_tick();
|
i->second->second_tick();
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
purge_connections();
|
||||||
|
|
||||||
// distribute the maximum upload rate among the peers
|
// distribute the maximum upload rate among the peers
|
||||||
control_upload_rates(m_upload_rate, m_connections);
|
control_upload_rates(m_upload_rate, m_connections);
|
||||||
|
|
||||||
|
@@ -637,23 +637,23 @@ namespace libtorrent
|
|||||||
void torrent::close_all_connections()
|
void torrent::close_all_connections()
|
||||||
{
|
{
|
||||||
for (peer_iterator i = m_connections.begin();
|
for (peer_iterator i = m_connections.begin();
|
||||||
i != m_connections.end();)
|
i != m_connections.end();
|
||||||
|
++i)
|
||||||
{
|
{
|
||||||
assert(i->second->associated_torrent() == this);
|
assert(i->second->associated_torrent() == this);
|
||||||
|
i->second->disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
detail::session_impl::connection_map::iterator j =
|
void torrent::disconnect_seeds()
|
||||||
m_ses.m_connections.find(i->second->get_socket());
|
{
|
||||||
|
for (peer_iterator i = m_connections.begin();
|
||||||
assert(j != m_ses.m_connections.end());
|
i != m_connections.end();
|
||||||
|
++i)
|
||||||
// in the destructor of the peer_connection
|
{
|
||||||
// it will remove itself from this torrent
|
assert(i->second->associated_torrent() == this);
|
||||||
// and from the list we're iterating over.
|
if (i->second->is_seed())
|
||||||
// so we need to increment the iterator riht
|
i->second->disconnect();
|
||||||
// away.
|
|
||||||
++i;
|
|
||||||
|
|
||||||
m_ses.m_connections.erase(j);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user