From b632d8bc2090879a4ca89d3e71934a3ee61eefde Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 15 Jan 2004 19:32:03 +0000 Subject: [PATCH] *** empty log message *** --- include/libtorrent/policy.hpp | 5 +++-- src/peer_connection.cpp | 3 +-- src/policy.cpp | 15 +++++++-------- src/session.cpp | 2 ++ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/libtorrent/policy.hpp b/include/libtorrent/policy.hpp index 0e14ac186..b1085db57 100755 --- a/include/libtorrent/policy.hpp +++ b/include/libtorrent/policy.hpp @@ -103,12 +103,13 @@ namespace libtorrent struct peer { - peer(const address& ip); + enum connection_type { connectable, not_connectable }; + + peer(const address& ip, peer::connection_type t); int total_download() const; int total_upload() const; - enum connection_type { local_connection, remote_connection }; // the ip/port pair this peer is or was connected on // if it was a remote (incoming) connection, type is // set thereafter. If it was a peer we got from the diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 0853be309..930538f3b 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -1609,8 +1609,7 @@ namespace libtorrent { if (m_socket->is_writable()) { - std::cout << "ERROR\n"; - assert(false); + std::cout << "ERROR, not good\n"; } } #endif diff --git a/src/policy.cpp b/src/policy.cpp index 268915031..fa7df94c3 100755 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -397,7 +397,7 @@ namespace libtorrent { if(i->connection) continue; if(i->banned) continue; - if(i->type == peer::remote_connection) continue; + if(!i->connectable) continue; assert(i->connected <= local_time); @@ -565,7 +565,7 @@ namespace libtorrent // we don't have ny info about this peer. // add a new entry - peer p(c.get_socket()->sender()); + peer p(c.get_socket()->sender(), peer::not_connectable); m_peers.push_back(p); i = m_peers.end()-1; } @@ -600,8 +600,7 @@ namespace libtorrent // we don't have ny info about this peer. // add a new entry - peer p(remote); - p.type = peer::local_connection; + peer p(remote, peer::connectable); m_peers.push_back(p); // the iterator is invalid // because of the push_back() @@ -609,7 +608,7 @@ namespace libtorrent } else { - i->type = peer::local_connection; + i->type = peer::connectable; // in case we got the ip from a remote connection, port is // not known, so save it. Client may also have changed port @@ -739,7 +738,7 @@ namespace libtorrent if (p == 0) return false; assert(!p->banned); assert(!p->connection); - assert(p->type != peer::remote_connection); + assert(p->connectable); p->connection = &m_torrent->connect_to_peer(p->id); p->connected = boost::posix_time::second_clock::local_time(); @@ -815,9 +814,9 @@ namespace libtorrent } #endif - policy::peer::peer(const address& pid) + policy::peer::peer(const address& pid, peer::connection_type t) : id(pid) - , type(remote_connection) + , type(t) , last_optimistically_unchoked( boost::gregorian::date(1970,boost::gregorian::Jan,1)) , connected(boost::gregorian::date(1970,boost::gregorian::Jan,1)) diff --git a/src/session.cpp b/src/session.cpp index c4667754b..4fb2e0403 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -532,6 +532,7 @@ namespace libtorrent i != writable_clients.end(); ++i) { + assert((*i)->is_writable()); connection_map::iterator p = m_connections.find(*i); // the connection may have been disconnected in the receive phase if (p == m_connections.end()) @@ -544,6 +545,7 @@ namespace libtorrent { assert(m_selector.is_writability_monitored(p->first)); assert(p->second->has_data()); + assert(p->second->get_socket()->is_writable()); p->second->send_data(); } catch(std::exception&)