From: Matthias Wachs Date: Tue, 11 Dec 2012 13:46:26 +0000 (+0000) Subject: (no commit message) X-Git-Tag: initial-import-from-subversion-38251~10495 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=19a850a8d8723fb70ce265304590d390f6782557;p=oweals%2Fgnunet.git --- diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index cf3c3411b..b2015108b 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -324,8 +324,6 @@ destroy_address (struct ATS_Address *addr) GNUNET_CONTAINER_multihashmap_remove (handle->addresses, &addr->peer.hashPubKey, addr)); - - handle->s_del (handle->solver, handle->addresses, addr); free_address (addr); return ret; } diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c index b379a5b2e..fd33fd7e6 100644 --- a/src/ats/gnunet-service-ats_addresses_simplistic.c +++ b/src/ats/gnunet-service-ats_addresses_simplistic.c @@ -212,10 +212,14 @@ update_quota_per_network (struct GAS_SIMPLISTIC_Handle *s, struct Network *net, struct ATS_Address *address_except) { - unsigned long long quota_in; - unsigned long long quota_out; + unsigned long long quota_in = 0; + unsigned long long quota_out = 0; struct AddressWrapper *cur; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Recalculate quota for network type `%s' for %u addresses (in/out): %llu/%llu \n", + net->desc, net->active_addresses, quota_in, quota_out); + if (net->active_addresses == 0) return; /* no addresses to update */ @@ -329,14 +333,25 @@ GAS_simplistic_address_delete (void *solver, struct GNUNET_CONTAINER_MultiHashMa { struct GAS_SIMPLISTIC_Handle *s = solver; struct Network *net; + struct AddressWrapper *aw; + /* Remove an adress completely, we have to: * - Remove from specific network - * - Decrease number of total addresses */ - net = (struct Network *) address->solver_information; + * - Decrease number of total addresses + * - If active: + * - decrease number of active addreses + * - update quotas + */ - GNUNET_break (0 < net->total_addresses); + net = (struct Network *) address->solver_information; + LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s address %p for peer `%s' from network `%s' (total: %u/ active: %u)\n", + (GNUNET_NO == address->active) ? "inactive" : "active", + address, GNUNET_i2s (&address->peer), + net->desc, net->total_addresses, net->active_addresses); + GNUNET_break (0 < net->total_addresses); + net->total_addresses --; if (GNUNET_YES == address->active) { @@ -348,6 +363,14 @@ GAS_simplistic_address_delete (void *solver, struct GNUNET_CONTAINER_MultiHashMa update_quota_per_network (s, net, NULL); } + for (aw = net->head; NULL != aw; aw = aw->next) + { + if (aw->addr == address) + break; + } + GNUNET_CONTAINER_DLL_remove (net->head, net->tail, aw); + GNUNET_free (aw); + } diff --git a/src/ats/test_ats_api_scheduling_destroy_address.c b/src/ats/test_ats_api_scheduling_destroy_address.c index c0d804077..40dc9d351 100644 --- a/src/ats/test_ats_api_scheduling_destroy_address.c +++ b/src/ats/test_ats_api_scheduling_destroy_address.c @@ -67,6 +67,18 @@ struct GNUNET_HELLO_Address test_hello_address; */ static void *test_session; +/** + * Test ats info + */ +struct GNUNET_ATS_Information test_ats_info[2]; + +/** + * Test ats count + */ +uint32_t test_ats_count; + + + static void create_test_address (struct Test_Address *dest, char * plugin, void *session, void *addr, size_t addrlen) { @@ -227,6 +239,13 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", GNUNET_i2s_full(&p.id)); + /* Prepare ATS Information */ + test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); + test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN); + test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); + test_ats_info[1].value = htonl(1); + test_ats_count = 2; + /* Adding address without session */ test_session = NULL; create_test_address (&test_addr, "test", test_session, "test", strlen ("test") + 1); @@ -234,7 +253,7 @@ run (void *cls, test_hello_address.transport_name = test_addr.plugin; test_hello_address.address = test_addr.addr; test_hello_address.address_length = test_addr.addr_len; - GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, NULL, 0); + GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, test_ats_info, 2); /* Request address */ GNUNET_ATS_suggest_address (sched_ats, &p.id);