From e755badb482f092280c8a30abf0c5ac92d85fcce Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 7 Sep 2011 12:56:02 +0000 Subject: [PATCH] adding statistics about connected peers --- .../gnunet-service-transport_neighbours.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 8937ae5a9..8f7d34b5d 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -226,6 +226,11 @@ static GNUNET_TRANSPORT_NotifyConnect connect_notify_cb; */ static GNUNET_TRANSPORT_NotifyDisconnect disconnect_notify_cb; +/** + * counter for connected neighbours + */ +static int neighbours_connected; + /** * Lookup a neighbour entry in the neighbours hash map. * @@ -394,6 +399,14 @@ disconnect_neighbour (struct NeighbourMapEntry *n) if (GNUNET_YES == n->is_connected) { n->is_connected = GNUNET_NO; + + GNUNET_assert (neighbours_connected > 0); + neighbours_connected--; + + GNUNET_STATISTICS_update (GST_stats, + gettext_noop + ("# peers connected"), + -1, GNUNET_NO); disconnect_notify_cb (callback_cls, &n->id); } GNUNET_assert (GNUNET_YES == @@ -480,6 +493,7 @@ GST_neighbours_stop () GNUNET_CONTAINER_multihashmap_iterate (neighbours, &disconnect_all_neighbours, NULL); GNUNET_CONTAINER_multihashmap_destroy (neighbours); + GNUNET_assert (neighbours_connected == 0); neighbours = NULL; callback_cls = NULL; connect_notify_cb = NULL; @@ -581,6 +595,12 @@ try_connect_using_address (void *cls, const struct GNUNET_PeerIdentity *target, ats_count); if (GNUNET_YES == was_connected) return; + + neighbours_connected++; + GNUNET_STATISTICS_update (GST_stats, + gettext_noop + ("# peers connected"), + 1, GNUNET_NO); connect_notify_cb (callback_cls, target, n->ats, n->ats_count); } -- 2.25.1