diff --git a/ChangeLog b/ChangeLog index 90596a4b1..ffe6a8b57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 1.1.1 release + * fixed dht stats counters that weren't being updated * make sure add_torrent_alert is always posted before other alerts for the torrent * fixed peer-class leak when settings per-torrent rate limits diff --git a/simulation/test_dht.cpp b/simulation/test_dht.cpp index b671ece3e..6a19a6ca9 100644 --- a/simulation/test_dht.cpp +++ b/simulation/test_dht.cpp @@ -39,6 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/settings_pack.hpp" #include "libtorrent/session_settings.hpp" #include "libtorrent/session.hpp" +#include "libtorrent/session_stats.hpp" #include "libtorrent/alert_types.hpp" #include "libtorrent/deadline_timer.hpp" #include "libtorrent/socket_io.hpp" @@ -78,6 +79,11 @@ TORRENT_TEST(dht_bootstrap) num_nodes = c; print_routing_table(p->routing_table); } + else if (lt::session_stats_alert const* sa = lt::alert_cast(a)) + { + int const dht_nodes = lt::find_metric_idx("dht.nodes"); + TEST_CHECK(sa->values[dht_nodes] > 2); + } } // terminate? , [&](int ticks, lt::session& ses) -> bool @@ -112,6 +118,7 @@ TORRENT_TEST(dht_bootstrap) } if (ticks > 2) { + ses.post_session_stats(); printf("depth: %d nodes: %d\n", routing_table_depth, num_nodes); TEST_CHECK(routing_table_depth >= 9); TEST_CHECK(num_nodes >= 115); diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index efeb77016..51be55850 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #ifdef TORRENT_USE_VALGRIND @@ -728,6 +729,12 @@ void node::update_stats_counters(counters& c) const c.set_value(counters::dht_peers, dht_cnt.peers); c.set_value(counters::dht_immutable_data, dht_cnt.immutable_data); c.set_value(counters::dht_mutable_data, dht_cnt.mutable_data); + + int nodes, replacements; + boost::tie(nodes, replacements, boost::tuples::ignore) = size(); + c.set_value(counters::dht_nodes, nodes); + c.set_value(counters::dht_node_cache, replacements); + c.set_value(counters::dht_allocated_observers, m_rpc.num_allocated_observers()); } #ifndef TORRENT_NO_DEPRECATE