From: Matthias Wachs Date: Fri, 11 Jan 2013 16:32:10 +0000 (+0000) Subject: changes X-Git-Tag: initial-import-from-subversion-38251~10211 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=db8b7bea43fb5cb18b9217bbf6afdca7fa965c91;p=oweals%2Fgnunet.git changes --- diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c index 60fbfee16..c5e774f56 100644 --- a/src/ats/gnunet-service-ats_addresses_simplistic.c +++ b/src/ats/gnunet-service-ats_addresses_simplistic.c @@ -447,29 +447,40 @@ update_quota_per_network (struct GAS_SIMPLISTIC_Handle *s, total_prefs = 0.0; for (cur = net->head; NULL != cur; cur = cur->next) { - t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey); - if (NULL == t) - total_prefs += DEFAULT_PREFERENCE; - else - total_prefs += (*t); + if (GNUNET_YES == cur->addr->active) + { + t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey); + if (NULL == t) + total_prefs += DEFAULT_PREFERENCE; + else + total_prefs += (*t); + } } for (cur = net->head; NULL != cur; cur = cur->next) { - cur_pref = 0.0; - t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey); - if (NULL == t) - cur_pref = DEFAULT_PREFERENCE; + if (GNUNET_YES == cur->addr->active) + { + cur_pref = 0.0; + t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey); + if (NULL == t) + cur_pref = DEFAULT_PREFERENCE; + else + cur_pref = (*t); + quota_in = min_bw + (cur_pref / total_prefs) * (float) remaining_quota_in; + quota_out = min_bw + (cur_pref / total_prefs) * (float) remaining_quota_out; + + LOG (GNUNET_ERROR_TYPE_DEBUG, + "New quota for peer `%s' with preference (cur/total) %.3f/%.3f (in/out): %llu /%llu\n", + GNUNET_i2s (&cur->addr->peer), + cur_pref, total_prefs, + quota_in, quota_out); + } else - cur_pref = (*t); - quota_in = min_bw + (cur_pref / total_prefs) * (float) remaining_quota_in; - quota_out = min_bw + (cur_pref / total_prefs) * (float) remaining_quota_out; - LOG (GNUNET_ERROR_TYPE_DEBUG, - "New quota for peer `%s' with preference (cur/total) %.3f/%.3f (in/out): %llu /%llu\n", - GNUNET_i2s (&cur->addr->peer), - cur_pref, - total_prefs, - quota_in, - quota_out); + { + quota_in = 0; + quota_out = 0; + } + quota_in_used += quota_in; quota_out_used += quota_out; /* Prevent overflow due to rounding errors */ @@ -496,12 +507,12 @@ update_quota_per_network (struct GAS_SIMPLISTIC_Handle *s, quota_out_used); if (quota_out_used > quota_out) LOG (GNUNET_ERROR_TYPE_WARNING, - "DEBUG! Total inbount bandwidth assigned is larget than allowed %llu /%llu\n", + "DEBUG! Total inbound bandwidth assigned is larget than allowed %llu /%llu\n", quota_out_used, quota_out); /* FIXME: Can happen atm, we have some rounding error */ if (quota_in_used > quota_in) LOG (GNUNET_ERROR_TYPE_WARNING, - "DEBUG! Total inbount bandwidth assigned is larget than allowed %llu /%llu\n", + "DEBUG! Total inbound bandwidth assigned is larget than allowed %llu /%llu\n", quota_in_used, quota_in); /* FIXME: Can happen atm, we have some rounding error */ } diff --git a/src/ats/test_ats_simplistic_change_preference.c b/src/ats/test_ats_simplistic_change_preference.c index 5adf87c75..6ce2b38a9 100644 --- a/src/ats/test_ats_simplistic_change_preference.c +++ b/src/ats/test_ats_simplistic_change_preference.c @@ -146,20 +146,23 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, { if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[0], test_session[0])) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct address `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n", + stage, GNUNET_i2s (&address->peer)); ret = 0; } else { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid address `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n", + stage, GNUNET_i2s (&address->peer)); ret = 1; } if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect ats info \n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n", + stage); ret = 1; } @@ -193,7 +196,67 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, stage ++; GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id); + GNUNET_ATS_suggest_address (sched_ats, &p[1].id); + return; + } + if (1 == stage) + { + if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[1], test_session[1])) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n", + stage, + GNUNET_i2s (&address->peer)); + ret = 0; + } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n", + stage, + GNUNET_i2s (&address->peer)); + ret = 1; + } + + if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n", + stage); + ret = 1; + } + + if (bw_in > wan_quota_in) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than allowed quota %llu \n", + bw_in, wan_quota_in); + ret = 1; + } + else + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u, allowed quota %llu \n", + bw_in, wan_quota_in); + + if (bw_out > wan_quota_out) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u bigger than allowed quota %llu \n", + bw_out, wan_quota_out); + ret = 1; + } + else + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u, allowed quota %llu \n", + bw_out, wan_quota_out); + + if (1 == ret) + { + GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id); + GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id); + GNUNET_SCHEDULER_add_now (&end, NULL); + return; + } + + stage ++; + + GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id); + GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id); GNUNET_SCHEDULER_add_now (&end, NULL); + return; } }