gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r16721 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r16721 - gnunet/src/transport
Date: Wed, 7 Sep 2011 14:56:02 +0200

Author: wachs
Date: 2011-09-07 14:56:02 +0200 (Wed, 07 Sep 2011)
New Revision: 16721

Modified:
   gnunet/src/transport/gnunet-service-transport_neighbours.c
Log:
adding statistics about connected peers


Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2011-09-07 
12:08:50 UTC (rev 16720)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2011-09-07 
12:56:02 UTC (rev 16721)
@@ -227,6 +227,11 @@
 static GNUNET_TRANSPORT_NotifyDisconnect disconnect_notify_cb;
 
 /**
+ * counter for connected neighbours
+ */
+static int neighbours_connected;
+
+/**
  * Lookup a neighbour entry in the neighbours hash map.
  *
  * @param pid identity of the peer to look up
@@ -394,6 +399,14 @@
   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 @@
   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 @@
                                     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);
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]