diff --git a/docs/manual.html b/docs/manual.html index 74d2de0c9..e4826ce05 100755 --- a/docs/manual.html +++ b/docs/manual.html @@ -1755,7 +1755,10 @@ all peers. The rates are given as the number of bytes per second. The total transfer rate of payload only, not counting protocol chatter. This might be slightly smaller than the other rates, but if projected over a long time (e.g. when calculating ETA:s) the difference may be noticable.

-

num_peers is the number of peers this torrent currently is connected to.

+

num_peers is the number of peers this torrent currently is connected to. +Peer connections that are in the half-open state (is attempting to connect) +or are queued for later connection attempt do not count. Although they are +visible in the peer list when you call get_peer_info().

num_complete and num_incomplete are set to -1 if the tracker did not send any scrape data in its announce reply. This data is optional and may not be available from all trackers. If these are not -1, they are the total diff --git a/docs/manual.rst b/docs/manual.rst index d571b6255..3132aa0aa 100755 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -1720,6 +1720,9 @@ be slightly smaller than the other rates, but if projected over a long time (e.g. when calculating ETA:s) the difference may be noticable. ``num_peers`` is the number of peers this torrent currently is connected to. +Peer connections that are in the half-open state (is attempting to connect) +or are queued for later connection attempt do not count. Although they are +visible in the peer list when you call `get_peer_info()`_. ``num_complete`` and ``num_incomplete`` are set to -1 if the tracker did not send any scrape data in its announce reply. This data is optional and may diff --git a/src/session.cpp b/src/session.cpp index b676e7391..df30c5b81 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -710,7 +710,7 @@ namespace libtorrent { namespace detail #endif p->second->set_failed(); - m_selector.remove(*i); +// m_selector.remove(*i); m_connections.erase(p); } } @@ -772,6 +772,7 @@ namespace libtorrent { namespace detail connection_map::iterator p = m_connections.find(*i); if(p == m_connections.end()) { + assert(m_half_open.find(*i) == m_half_open.end()); m_selector.remove(*i); } else @@ -813,7 +814,7 @@ namespace libtorrent { namespace detail // the connection wants to disconnect for some reason, remove it // from the connection-list p->second->set_failed(); - m_selector.remove(*i); +// m_selector.remove(*i); m_connections.erase(p); } } @@ -834,7 +835,7 @@ namespace libtorrent { namespace detail { connection_map::iterator p = m_connections.find(*i); - m_selector.remove(*i); +// m_selector.remove(*i); // the connection may have been disconnected in the receive or send phase if (p != m_connections.end()) { @@ -930,7 +931,7 @@ namespace libtorrent { namespace detail #endif j->second->set_failed(); - m_selector.remove(j->first); +// m_selector.remove(j->first); m_connections.erase(j); continue; } diff --git a/src/torrent.cpp b/src/torrent.cpp index 0ec20e462..68f7d7bfc 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1354,7 +1354,12 @@ namespace libtorrent torrent_status st; st.block_size = block_size(); - st.num_peers = num_peers(); + + + st.num_peers = (int)std::count_if(m_connections.begin(), m_connections.end(), + bind(std::logical_not(), boost::bind(&peer_connection::is_connecting, + boost::bind(&std::map::value_type::second, _1)))); + st.num_complete = m_complete; st.num_incomplete = m_incomplete; st.paused = m_paused;