aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-01-21 16:58:57 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-01-21 16:58:57 +0000
commitb07a598332b5d5ef4a479b5faeea44a2a4e3c88b (patch)
tree3af2f395732fe2ef33459be025f28dba6dc29ede /src
parent46195e68664242e770a517f2b5d90fde2f1cdd0a (diff)
downloadgnunet-b07a598332b5d5ef4a479b5faeea44a2a4e3c88b.tar.gz
gnunet-b07a598332b5d5ef4a479b5faeea44a2a4e3c88b.zip
changes to aging
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-service-ats_addresses_simplistic.c32
1 files changed, 28 insertions, 4 deletions
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
1234preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1234preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1235{ 1235{
1236 int i; 1236 int i;
1237 double *t = NULL;
1237 double backup; 1238 double backup;
1238 struct PreferencePeer *p = cls; 1239 struct PreferencePeer *p = cls;
1239 GNUNET_assert (NULL != p); 1240 GNUNET_assert (NULL != p);
@@ -1244,6 +1245,19 @@ preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1244 LOG (GNUNET_ERROR_TYPE_DEBUG, "Aging preferences for peer `%s'\n", 1245 LOG (GNUNET_ERROR_TYPE_DEBUG, "Aging preferences for peer `%s'\n",
1245 GNUNET_i2s (&p->id)); 1246 GNUNET_i2s (&p->id));
1246 1247
1248 /* Issue for aging :
1249 *
1250 * Not for every peer preference values are set by default, so reducing the
1251 * absolute preference value does not help for aging because it does not have
1252 * influence on the relative values.
1253 *
1254 * So we have to reduce the relative value to have an immediate impact on
1255 * quota calculation. In addition we cannot call recalculate_preferences here
1256 * but instead reduce the absolute value to have an aging impact on future
1257 * calls to change_preference where recalculate_preferences is called
1258 *
1259 */
1260 /* Aging absolute values: */
1247 for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) 1261 for (i = 0; i < GNUNET_ATS_PreferenceCount; i++)
1248 { 1262 {
1249 if (p->f[i] > 1.0) 1263 if (p->f[i] > 1.0)
@@ -1254,10 +1268,20 @@ preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1254 GNUNET_i2s (&p->id), backup, p->f[i]); 1268 GNUNET_i2s (&p->id), backup, p->f[i]);
1255 } 1269 }
1256 } 1270 }
1257 1271 /* Updating relative value */
1258 recalculate_preferences (p); 1272 t = GNUNET_CONTAINER_multihashmap_get (p->s->prefs, &p->id.hashPubKey);
1259 update_all_networks (p->s); 1273 if (NULL == t)
1260 1274 {
1275 GNUNET_break (0);
1276 }
1277 else
1278 {
1279 if ((*t) > 1.0)
1280 (*t) = (*t) * PREF_AGING_FACTOR;
1281 else
1282 (*t) = 1.0;
1283 update_all_networks (p->s);
1284 }
1261 p->aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL, 1285 p->aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL,
1262 &preference_aging, p); 1286 &preference_aging, p);
1263} 1287}