/** * Reduce absolute preferences since they got old. * * @param cls unused */ static void preference_aging (void *cls) { struct AgeContext ac; aging_task = NULL; GAS_plugin_solver_lock (); ac.values_to_update = 0; for (ac.cur_client = pc_head; NULL != ac.cur_client; ac.cur_client = ac.cur_client->next) GNUNET_CONTAINER_multipeermap_iterate (ac.cur_client->peer2pref, &age_values, &ac); GAS_plugin_solver_unlock (); if (ac.values_to_update > 0) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Rescheduling aging task due to %u elements remaining to age\n", ac.values_to_update); if (NULL == aging_task) aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL, &preference_aging, NULL); } else { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No values to age left, not rescheduling aging task\n"); } }
/** * Update and normalize atsi performance information * * @param address the address to update */ void GAS_normalization_update_property (struct ATS_Address *address) { const struct GNUNET_ATS_Properties *prop = &address->properties; struct PropertyRange range; LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating properties for peer `%s'\n", GNUNET_i2s (&address->peer)); GAS_plugin_solver_lock (); update_avg (prop->delay.rel_value_us, &address->norm_delay); update_avg (prop->distance, &address->norm_distance); update_avg (prop->utilization_in, &address->norm_utilization_in); update_avg (prop->utilization_in, &address->norm_utilization_out); init_range (&range); GNUNET_CONTAINER_multipeermap_iterate (GSA_addresses, &find_min_max_it, &range); if (0 != memcmp (&range, &property_range, sizeof (struct PropertyRange))) { /* limits changed, (re)normalize all addresses */ property_range = range; GNUNET_CONTAINER_multipeermap_iterate (GSA_addresses, &normalize_address, NULL); GNUNET_CONTAINER_multipeermap_iterate (GSA_addresses, ¬ify_change, NULL); } else { /* renormalize just this one address */ normalize_address (NULL, &address->peer, address); notify_change (NULL, &address->peer, address); } GAS_plugin_solver_unlock (); }