From 4e6ef3777767569c4b92ca630837d1a1b1248e4f Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 3 Apr 2013 11:12:10 +0000 Subject: [PATCH] fixed network switching --- src/ats/gnunet-service-ats_addresses.c | 5 ++-- .../gnunet-service-ats_addresses_simplistic.c | 28 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index ce4346e55..52b60cba1 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -895,9 +895,6 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle, "ADDRESS UPDATE", GNUNET_i2s (peer), aa); - /* Tell solver about update */ - handle->s_update (handle->solver, handle->addresses, aa, session_id, aa->used, atsi, atsi_count); - /* Update address */ atsi_delta = NULL; if (GNUNET_YES == disassemble_ats_information (aa, atsi, atsi_count, &atsi_delta, &atsi_delta_count)) @@ -911,6 +908,8 @@ GAS_addresses_update (struct GAS_Addresses_Handle *handle, aa->assigned_bw_out, aa->assigned_bw_in); } + /* Tell solver about update */ + handle->s_update (handle->solver, handle->addresses, aa, session_id, aa->used, atsi_delta, atsi_delta_count); GNUNET_free_non_null (atsi_delta); } diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c index c773eaa0c..1e847cb31 100644 --- a/src/ats/gnunet-service-ats_addresses_simplistic.c +++ b/src/ats/gnunet-service-ats_addresses_simplistic.c @@ -937,22 +937,22 @@ GAS_simplistic_address_update (void *solver, struct ATS_Address *address, uint32_t session, int in_use, - const struct GNUNET_ATS_Information *atsi, - uint32_t atsi_count) + const struct GNUNET_ATS_Information *prev_ats, + uint32_t prev_atsi_count) { struct ATS_Address *new; struct GAS_SIMPLISTIC_Handle *s = (struct GAS_SIMPLISTIC_Handle *) solver; int i; - uint32_t value; - uint32_t type; + uint32_t prev_value; + uint32_t prev_type; uint32_t addr_net; int save_active = GNUNET_NO; struct Network *new_net = NULL; - for (i = 0; i < atsi_count; i++) + for (i = 0; i < prev_atsi_count; i++) { - type = ntohl (atsi[i].type); - value = ntohl (atsi[i].value); - switch (type) + prev_type = ntohl (prev_ats[i].type); + prev_value = ntohl (prev_ats[i].value); + switch (prev_type) { case GNUNET_ATS_UTILIZATION_UP: //if (address->atsp_utilization_out.value__ != atsi[i].value) @@ -989,24 +989,24 @@ GAS_simplistic_address_update (void *solver, GNUNET_break (0); addr_net = GNUNET_ATS_NET_UNSPECIFIED; } - if (addr_net != value) + if (addr_net != prev_value) { LOG (GNUNET_ERROR_TYPE_DEBUG, "Network type changed, moving %s address from `%s' to `%s'\n", (GNUNET_YES == address->active) ? "active" : "inactive", - GNUNET_ATS_print_network_type(addr_net), - GNUNET_ATS_print_network_type(value)); + GNUNET_ATS_print_network_type(prev_value), + GNUNET_ATS_print_network_type(addr_net)); save_active = address->active; /* remove from old network */ GAS_simplistic_address_delete (solver, addresses, address, GNUNET_NO); /* set new network type */ - new_net = find_network (solver, value); + new_net = find_network (solver, addr_net); address->solver_information = new_net; /* Add to new network and update*/ - GAS_simplistic_address_add (solver, addresses, address, value); + GAS_simplistic_address_add (solver, addresses, address, addr_net); if (GNUNET_YES == save_active) { /* check if bandwidth available in new network */ @@ -1043,7 +1043,7 @@ GAS_simplistic_address_update (void *solver, break; default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Received unsupported ATS type %u\n", type); + "Received unsupported ATS type %u\n", prev_type); GNUNET_break (0); break; -- 2.25.1