From b07a598332b5d5ef4a479b5faeea44a2a4e3c88b Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 21 Jan 2013 16:58:57 +0000 Subject: changes to aging --- src/ats/gnunet-service-ats_addresses_simplistic.c | 32 ++++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c index 4f3ec08b2..47682171b 100644 --- a/src/ats/gnunet-service-ats_addresses_simplistic.c +++ b/src/ats/gnunet-service-ats_addresses_simplistic.c @@ -1234,6 +1234,7 @@ static void preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { int i; + double *t = NULL; double backup; struct PreferencePeer *p = cls; GNUNET_assert (NULL != p); @@ -1244,6 +1245,19 @@ preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) LOG (GNUNET_ERROR_TYPE_DEBUG, "Aging preferences for peer `%s'\n", GNUNET_i2s (&p->id)); + /* Issue for aging : + * + * Not for every peer preference values are set by default, so reducing the + * absolute preference value does not help for aging because it does not have + * influence on the relative values. + * + * So we have to reduce the relative value to have an immediate impact on + * quota calculation. In addition we cannot call recalculate_preferences here + * but instead reduce the absolute value to have an aging impact on future + * calls to change_preference where recalculate_preferences is called + * + */ + /* Aging absolute values: */ for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) { if (p->f[i] > 1.0) @@ -1254,10 +1268,20 @@ preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_i2s (&p->id), backup, p->f[i]); } } - - recalculate_preferences (p); - update_all_networks (p->s); - + /* Updating relative value */ + t = GNUNET_CONTAINER_multihashmap_get (p->s->prefs, &p->id.hashPubKey); + if (NULL == t) + { + GNUNET_break (0); + } + else + { + if ((*t) > 1.0) + (*t) = (*t) * PREF_AGING_FACTOR; + else + (*t) = 1.0; + update_all_networks (p->s); + } p->aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL, &preference_aging, p); } -- cgit v1.2.3