From b9e53953acedad90fcc54c8245da5a9a29969fc4 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Tue, 15 Apr 2014 15:31:15 +0000 Subject: [PATCH] stop pg generation on address deletion --- src/ats/gnunet-ats-solver-eval.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c index e0b0724ea..e2862158b 100644 --- a/src/ats/gnunet-ats-solver-eval.c +++ b/src/ats/gnunet-ats-solver-eval.c @@ -721,13 +721,15 @@ set_pref_task (void *cls, } static struct PreferenceGenerator * -find_pref_gen (unsigned int peer, unsigned int address, - enum GNUNET_ATS_PreferenceKind kind) +find_pref_gen (unsigned int peer, enum GNUNET_ATS_PreferenceKind kind) { struct PreferenceGenerator *cur; for (cur = pref_gen_head; NULL != cur; cur = cur->next) - if ((cur->peer == peer) && (cur->kind == kind)) - return cur; + if (cur->peer == peer) + { + if ((cur->kind == kind) || (GNUNET_ATS_PREFERENCE_END == kind)) + return cur; + } return NULL; } @@ -1844,6 +1846,7 @@ enforce_del_address (struct GNUNET_ATS_TEST_Operation *op) struct TestPeer *p; struct TestAddress *a; struct AddressLookupCtx ctx; + struct PropertyGenerator *pg; if (NULL == (p = find_peer_by_id (op->peer_id))) { @@ -1874,6 +1877,11 @@ enforce_del_address (struct GNUNET_ATS_TEST_Operation *op) return; } + while (NULL != (pg = find_prop_gen (p->id, a->aid, 0))) + { + GNUNET_ATS_solver_generate_property_stop (pg); + } + GNUNET_CONTAINER_DLL_remove(p->addr_head, p->addr_tail, a); GNUNET_free (a); @@ -1940,7 +1948,7 @@ static void enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) { struct PreferenceGenerator *pg; - if (NULL != (pg = find_pref_gen (op->peer_id, op->address_id, op->pref_type))) + if (NULL != (pg = find_pref_gen (op->peer_id, op->pref_type))) { GNUNET_ATS_solver_generate_preferences_stop (pg); GNUNET_free (pg); @@ -1968,7 +1976,7 @@ enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) static void enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) { - struct PreferenceGenerator *pg = find_pref_gen(op->peer_id, op->address_id, + struct PreferenceGenerator *pg = find_pref_gen(op->peer_id, op->pref_type); if (NULL != pg) GNUNET_ATS_solver_generate_preferences_stop (pg); -- 2.25.1