From e0a17cc294317482060b695b7569d5bdd3b01c2f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Feb 2014 18:48:10 +0000 Subject: [PATCH] implementing #3296 --- src/transport/transport_api.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 8d54c361e..1acf14d41 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -438,6 +438,24 @@ outbound_bw_tracker_update (void *cls) } +/** + * Function called by the bandwidth tracker if we have excess + * bandwidth. + * + * @param cls the `struct Neighbour` that has excess bandwidth + */ +static void +notify_excess_cb (void *cls) +{ + struct Neighbour *n = cls; + struct GNUNET_TRANSPORT_Handle *h = n->h; + + if (NULL != h->neb_cb) + h->neb_cb (h->cls, + &n->id); +} + + /** * Add neighbour to our list * @@ -457,10 +475,12 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, n->h = h; n->is_ready = GNUNET_YES; n->traffic_overhead = 0; - GNUNET_BANDWIDTH_tracker_init (&n->out_tracker, - outbound_bw_tracker_update, n, - GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, - MAX_BANDWIDTH_CARRY_S); + GNUNET_BANDWIDTH_tracker_init2 (&n->out_tracker, + &outbound_bw_tracker_update, n, + GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, + MAX_BANDWIDTH_CARRY_S, + ¬ify_excess_cb, + n); GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (h->neighbours, &n->id, n, -- 2.25.1