aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_ats.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport_ats.c')
-rw-r--r--src/transport/gnunet-service-transport_ats.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c
index 430c00ba6..bc20038f1 100644
--- a/src/transport/gnunet-service-transport_ats.c
+++ b/src/transport/gnunet-service-transport_ats.c
@@ -85,6 +85,21 @@ struct FindClosure
85 85
86 86
87/** 87/**
88 * Provide an update on the `p2a` map size to statistics.
89 * This function should be called whenever the `p2a` map
90 * is changed.
91 */
92static void
93publish_p2a_stat_update ()
94{
95 GNUNET_STATISTICS_set (GST_stats,
96 gettext_noop ("# Addresses given to ATS"),
97 GNUNET_CONTAINER_multipeermap_size (p2a),
98 GNUNET_NO);
99}
100
101
102/**
88 * Find matching address info. 103 * Find matching address info.
89 * 104 *
90 * @param cls the `struct FindClosure` 105 * @param cls the `struct FindClosure`
@@ -299,6 +314,7 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
299 &ai->address->peer, 314 &ai->address->peer,
300 ai, 315 ai,
301 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 316 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
317 publish_p2a_stat_update ();
302} 318}
303 319
304 320
@@ -480,6 +496,7 @@ GST_ats_expire_address (const struct GNUNET_HELLO_Address *address)
480 GNUNET_CONTAINER_multipeermap_remove (p2a, 496 GNUNET_CONTAINER_multipeermap_remove (p2a,
481 &address->peer, 497 &address->peer,
482 ai)); 498 ai));
499 publish_p2a_stat_update ();
483 GNUNET_break (NULL == ai->session); 500 GNUNET_break (NULL == ai->session);
484 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 501 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
485 "transport-ats", 502 "transport-ats",
@@ -518,6 +535,10 @@ destroy_ai (void *cls,
518 struct AddressInfo *ai = value; 535 struct AddressInfo *ai = value;
519 536
520 GNUNET_HELLO_address_free (ai->address); 537 GNUNET_HELLO_address_free (ai->address);
538 GNUNET_assert (GNUNET_YES ==
539 GNUNET_CONTAINER_multipeermap_remove (p2a,
540 key,
541 ai));
521 GNUNET_free (ai); 542 GNUNET_free (ai);
522 return GNUNET_OK; 543 return GNUNET_OK;
523} 544}
@@ -532,6 +553,7 @@ GST_ats_done ()
532 GNUNET_CONTAINER_multipeermap_iterate (p2a, 553 GNUNET_CONTAINER_multipeermap_iterate (p2a,
533 &destroy_ai, 554 &destroy_ai,
534 NULL); 555 NULL);
556 publish_p2a_stat_update ();
535 GNUNET_CONTAINER_multipeermap_destroy (p2a); 557 GNUNET_CONTAINER_multipeermap_destroy (p2a);
536 p2a = NULL; 558 p2a = NULL;
537} 559}