From: Matthias Wachs Date: Thu, 26 Sep 2013 14:49:30 +0000 (+0000) Subject: minor fixes X-Git-Tag: initial-import-from-subversion-38251~7035 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d2eeb1730e19a523647a94d77295bf3c46fbf33e;p=oweals%2Fgnunet.git minor fixes --- diff --git a/src/ats/gnunet-service-ats-solver_mlp.c b/src/ats/gnunet-service-ats-solver_mlp.c index 299639de8..0c7150092 100644 --- a/src/ats/gnunet-service-ats-solver_mlp.c +++ b/src/ats/gnunet-service-ats-solver_mlp.c @@ -991,13 +991,16 @@ mlp_propagate_results (void *cls, const struct GNUNET_HashCode *key, void *value if (GNUNET_NO == address->active) { /* Address was not used before, enabling address */ - LOG (GNUNET_ERROR_TYPE_DEBUG, "%s %.2f : enabling address\n", (1 == mlp_use) ? "[x]": "[ ]", mlp_bw_out); - address->active = GNUNET_YES; - address->assigned_bw_in.value__ = htonl (mlp_bw_in); - mlpi->b_in.value__ = htonl(mlp_bw_in); - address->assigned_bw_out.value__ = htonl (mlp_bw_out); - mlpi->b_out.value__ = htonl(mlp_bw_out); - mlp->bw_changed_cb (mlp->bw_changed_cb_cls, address); + LOG (GNUNET_ERROR_TYPE_DEBUG, "%s %.2f : enabling address\n", + (1 == mlp_use) ? "[x]": "[ ]", mlp_bw_out); + address->active = GNUNET_YES; + address->assigned_bw_in.value__ = htonl (mlp_bw_in); + mlpi->b_in.value__ = htonl(mlp_bw_in); + address->assigned_bw_out.value__ = htonl (mlp_bw_out); + mlpi->b_out.value__ = htonl(mlp_bw_out); + + mlp->bw_changed_cb (mlp->bw_changed_cb_cls, address); + return GNUNET_OK; } else if (GNUNET_YES == address->active) { @@ -1011,11 +1014,13 @@ mlp_propagate_results (void *cls, const struct GNUNET_HashCode *key, void *value mlpi->b_in.value__ = htonl(mlp_bw_in); address->assigned_bw_out.value__ = htonl (mlp_bw_out); mlpi->b_out.value__ = htonl(mlp_bw_out); + mlp->bw_changed_cb (mlp->bw_changed_cb_cls, address); + return GNUNET_OK; } } else - GNUNET_break (0); + GNUNET_break (0); } else if (GLP_NO == mlp_use) { @@ -1026,6 +1031,7 @@ mlp_propagate_results (void *cls, const struct GNUNET_HashCode *key, void *value /* Address was not used before, nothing to do */ LOG (GNUNET_ERROR_TYPE_DEBUG, "%s %.2f : no change\n", (1 == mlp_use) ? "[x]": "[ ]", mlp_bw_out); + return GNUNET_OK; } else if (GNUNET_YES == address->active) { @@ -1039,6 +1045,7 @@ mlp_propagate_results (void *cls, const struct GNUNET_HashCode *key, void *value address->assigned_bw_out = BANDWIDTH_ZERO; mlpi->b_out.value__ = htonl(mlp_bw_out); //mlp->bw_changed_cb (mlp->bw_changed_cb_cls, address); + return GNUNET_OK; } else GNUNET_break (0); diff --git a/src/ats/test_ats_solver_alternative_after_delete_address.c b/src/ats/test_ats_solver_alternative_after_delete_address.c index 70f49fa73..f68bff773 100644 --- a/src/ats/test_ats_solver_alternative_after_delete_address.c +++ b/src/ats/test_ats_solver_alternative_after_delete_address.c @@ -25,7 +25,7 @@ */ /** * @file ats/test_ats_solver_add_address.c - * @brief solver test: add address, request address and wait for suggest + * @brief solver test: add 2 addresses, request address, delete, expect alternative * @author Christian Grothoff * @author Matthias Wachs */ @@ -108,9 +108,9 @@ int second_address_deleted = GNUNET_NO; int second_address_suggested = GNUNET_YES; -static const struct GNUNET_HELLO_Address *first_suggestion = NULL; +static struct GNUNET_HELLO_Address *first_suggestion = NULL; -static const struct GNUNET_HELLO_Address *second_suggestion = NULL; +static struct GNUNET_HELLO_Address *second_suggestion = NULL; static int @@ -140,7 +140,8 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } free_test_address (&test_addr); - + GNUNET_free_non_null (first_suggestion); + GNUNET_free_non_null (second_suggestion); ret = 0; } @@ -185,14 +186,15 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received 1st sugggestion for peer `%s' : `%s'\n", GNUNET_i2s (&address->peer), (char *) address->address); - first_suggestion = address; + first_suggestion = GNUNET_HELLO_address_copy (address); first_address_suggested = GNUNET_YES; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Deleting 1st address for peer `%s' : `%s'\n", GNUNET_i2s (&address->peer), (char *) address->address); - GNUNET_ATS_address_destroyed (sched_ats, address, session); first_address_deleted = GNUNET_YES; + return; } } @@ -219,18 +221,19 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, return; } - if (first_suggestion->address_length == address->address_length) + if (0 == memcmp (address->address, first_suggestion->address, + (first_suggestion->address_length < address->address_length) ? first_suggestion->address_length : address->address_length)) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Deleted address for peer `%s' was suggested after deletion: `%s'\n", - GNUNET_i2s (&address->peer), (char *) address->address); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Deleted 1st address for peer `%s' was suggested after deletion: `%s' `%s'\n", + GNUNET_i2s (&address->peer), (char *) address->address, first_suggestion->address); GNUNET_break (0); - //GNUNET_SCHEDULER_add_now (&end_badly, NULL); + GNUNET_SCHEDULER_add_now (&end_badly, NULL); return; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received 2nd sugggestion for peer `%s' : `%s'\n", GNUNET_i2s (&address->peer), (char *) address->address); - second_suggestion = address; + second_suggestion = GNUNET_HELLO_address_copy (address); second_address_suggested = GNUNET_YES; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Deleting 2nd address for peer `%s' : `%s'\n", @@ -239,8 +242,9 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, second_address_deleted = GNUNET_YES; return; } + } - if (GNUNET_YES ==second_address_deleted) + if (GNUNET_YES == second_address_deleted) { /* Expecting disconnect */ if ((ntohl(bandwidth_in.value__) == 0) &&