From: Matthias Wachs Date: Fri, 13 Jan 2012 14:49:41 +0000 (+0000) Subject: - more X-Git-Tag: initial-import-from-subversion-38251~15331 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6e19faa688d79c28b21d2e7382019148421dabf5;p=oweals%2Fgnunet.git - more --- diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index a5480e50e..019f0aceb 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -37,8 +37,17 @@ enum ATS_Mode { - SIMPLE, - MLP + /** + * Assign each peer an equal amount of bandwidth (bw) + * + * bw_per_peer = bw_total / #active addresses + */ + SIMPLE, + + /** + * Use MLP solver to assign bandwidth + */ + MLP }; static struct GNUNET_CONTAINER_MultiHashMap *addresses; @@ -51,6 +60,7 @@ static unsigned int active_addr_count; static int ats_mode; + /** * Update a bandwidth assignment for a peer. This trivial method currently * simply assigns the same share to all active connections. @@ -65,6 +75,8 @@ update_bw_it (void *cls, const GNUNET_HashCode * key, void *value) { struct ATS_Address *aa = value; + + /* Simple method */ if (GNUNET_YES != aa->active) return GNUNET_OK; GNUNET_assert (active_addr_count > 0); @@ -159,6 +171,12 @@ destroy_address (struct ATS_Address *addr) GNUNET_CONTAINER_multihashmap_remove (addresses, &addr->peer.hashPubKey, addr)); + +#if HAVE_LIBGLPK + if (ats_mode == MLP) + GAS_mlp_address_delete (addresses, addr); +#endif + if (GNUNET_YES == addr->active) { active_addr_count--; @@ -354,12 +372,21 @@ destroy_by_session_id (void *cls, const GNUNET_HashCode * key, void *value) /* session == 0 and addrlen == 0 : destroy address */ if (aa->addr_len == 0) + { (void) destroy_address (aa); + } + else + { + /* session was set to 0, update address */ +#if HAVE_LIBGLPK + if (ats_mode == MLP) + GAS_mlp_address_update (addresses, aa); +#endif + } return GNUNET_OK; } - void GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr,