Dht stats 1.1 (#720)

fix missing dht stats counter updates
This commit is contained in:
Arvid Norberg 2016-05-12 21:27:11 -04:00
parent 4057aa0391
commit 53bd03558c
3 changed files with 15 additions and 0 deletions

View File

@ -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

View File

@ -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<lt::session_stats_alert>(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);

View File

@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <utility>
#include <boost/bind.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/function/function1.hpp>
#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