From 1eef01cd60f92a3d77061d655c0217bd6f9ffce4 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 16 Jun 2014 10:10:59 +0000 Subject: notify performance monitors about destroyed addresses (for #3406) --- src/ats-tests/ats-testing.c | 52 +++--- src/ats-tests/gnunet-solver-eval.c | 1 - src/ats-tool/gnunet-ats.c | 43 ++++- src/ats/ats_api_performance.c | 30 +-- src/ats/gnunet-service-ats_addresses.c | 203 ++++++++++++++------- src/ats/gnunet-service-ats_performance.c | 58 +++--- src/ats/gnunet-service-ats_performance.h | 19 +- .../test_ats_api_performance_list_all_addresses.c | 3 +- src/ats/test_ats_solver_add_address.c | 6 - ...t_ats_solver_alternative_after_delete_address.c | 6 - src/dv/gnunet-service-dv.c | 10 +- src/fs/gnunet-service-fs.c | 2 +- src/include/gnunet_ats_service.h | 38 ++-- src/testbed/gnunet-daemon-latency-logger.c | 28 +-- 14 files changed, 311 insertions(+), 188 deletions(-) (limited to 'src') diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c index 6fda20311..a4016a120 100644 --- a/src/ats-tests/ats-testing.c +++ b/src/ats-tests/ats-testing.c @@ -541,14 +541,15 @@ do_comm_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } } + static void ats_performance_info_cb (void *cls, - const struct GNUNET_HELLO_Address *address, - int address_active, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, - const struct GNUNET_ATS_Information *ats, - uint32_t ats_count) + const struct GNUNET_HELLO_Address *address, + int address_active, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, + const struct GNUNET_ATS_Information *ats, + uint32_t ats_count) { struct BenchmarkPeer *me = cls; struct BenchmarkPartner *p; @@ -556,8 +557,6 @@ ats_performance_info_cb (void *cls, int log; char *peer_id; - - p = find_partner (me, &address->peer); if (NULL == p) { @@ -634,8 +633,11 @@ ats_performance_info_cb (void *cls, } } if (GNUNET_YES == log) - top->ats_perf_cb (cls, address, address_active, bandwidth_out, bandwidth_in, - ats, ats_count); + top->ats_perf_cb (cls, address, + address_active, + bandwidth_out, + bandwidth_in, + ats, ats_count); GNUNET_free(peer_id); } @@ -646,7 +648,9 @@ ats_perf_connect_adapter (void *cls, { struct BenchmarkPeer *me = cls; - me->ats_perf_handle = GNUNET_ATS_performance_init (cfg, ats_performance_info_cb, me); + me->ats_perf_handle = GNUNET_ATS_performance_init (cfg, + &ats_performance_info_cb, + me); if (NULL == me->ats_perf_handle) GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create ATS performance handle \n"); @@ -857,6 +861,7 @@ GNUNET_ATS_TEST_get_partner (int src, int dest) return &top->mps[src].partners[dest]; } + /** * Create a topology for ats testing * @@ -872,15 +877,14 @@ GNUNET_ATS_TEST_get_partner (int src, int dest) */ void GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, - unsigned int num_slaves, - unsigned int num_masters, - int test_core, - GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, - void *done_cb_cls, - GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb, - GNUNET_ATS_AddressInformationCallback log_request_cb) + unsigned int num_slaves, + unsigned int num_masters, + int test_core, + GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, + void *done_cb_cls, + GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb, + GNUNET_ATS_AddressInformationCallback log_request_cb) { - static struct GNUNET_CORE_MessageHandler handlers[] = { {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 }, @@ -894,7 +898,7 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, top->done_cb_cls = done_cb_cls; top->test_core = test_core; top->transport_recv_cb = transport_recv_cb; - top->ats_perf_cb = log_request_cb; + top->ats_perf_cb = &log_request_cb; top->mps = GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer)); top->sps = GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer)); @@ -905,10 +909,13 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); (void) GNUNET_TESTBED_test_run (name, cfg_file, - num_slaves + num_masters, event_mask, &controller_event_cb, NULL, - &main_run, NULL); + num_slaves + num_masters, + event_mask, + &controller_event_cb, NULL, + &main_run, NULL); } + /** * Shutdown topology */ @@ -917,7 +924,6 @@ GNUNET_ATS_TEST_shutdown_topology (void) { if (NULL == top) return; - GNUNET_SCHEDULER_shutdown(); } diff --git a/src/ats-tests/gnunet-solver-eval.c b/src/ats-tests/gnunet-solver-eval.c index 91507a7f4..9432f429d 100644 --- a/src/ats-tests/gnunet-solver-eval.c +++ b/src/ats-tests/gnunet-solver-eval.c @@ -33,7 +33,6 @@ /** * Experiments */ - const char * print_op (enum OperationType op) { diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index a1e2df7a6..0c7b19790 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c @@ -438,7 +438,7 @@ transport_addr_to_str_cb (void *cls, ntohl (pr->bandwidth_out.value__), ntohl (pr->bandwidth_in.value__), ats_str); - GNUNET_free(ats_str); + GNUNET_free (ats_str); } @@ -490,8 +490,10 @@ find_address_it (void *cls, * * @param cls closure (NULL) * @param address the address, NULL if ATS service was disconnected - * @param address_active is this address actively used to maintain a connection - to a peer + * @param active #GNUNET_YES if this address is actively used + * to maintain a connection to a peer; + * #GNUNET_NO if the address is not actively used; + * #GNUNET_SYSERR if this address is no longer available for ATS * @param bandwidth_out assigned outbound bandwidth for the connection * @param bandwidth_in assigned inbound bandwidth for the connection * @param ats performance data for the address (as far as known) @@ -528,6 +530,34 @@ ats_perf_mon_cb (void *cls, NULL); return; } + if (GNUNET_SYSERR == active) + { + /* remove address */ + struct AddressFindCtx actx; + + actx.src = address; + actx.res = NULL; + GNUNET_CONTAINER_multipeermap_get_multiple (addresses, + &address->peer, + &find_address_it, + &actx); + if (NULL == actx.res) + { + GNUNET_break (0); + return; + } + GNUNET_break (GNUNET_OK == + GNUNET_CONTAINER_multipeermap_remove (addresses, + &address->peer, + actx.res)); + FPRINTF (stderr, + _("Removed address of peer `%s' with plugin `%s'\n"), + GNUNET_i2s (&address->peer), + actx.res->address->transport_name); + GNUNET_HELLO_address_free (actx.res); + GNUNET_free (actx.res); + return; + } if (GNUNET_NO == verbose) { @@ -536,7 +566,6 @@ ats_perf_mon_cb (void *cls, actx.src = address; actx.res = NULL; - GNUNET_CONTAINER_multipeermap_get_multiple (addresses, &address->peer, &find_address_it, @@ -836,7 +865,11 @@ testservice_ats (void *cls, _("Cannot connect to ATS service, exiting...\n")); alh = GNUNET_ATS_performance_list_addresses (ph, - (NULL == pid_str) ? NULL : &pid, GNUNET_NO, ats_perf_cb, NULL); + (NULL == pid_str) + ? NULL + : &pid, + GNUNET_NO, + &ats_perf_cb, NULL); if (NULL == alh) { FPRINTF (stderr, diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c index 35dcc558f..ab242a0e9 100644 --- a/src/ats/ats_api_performance.c +++ b/src/ats/ats_api_performance.c @@ -367,7 +367,7 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph, ats_count = ntohl (pi->ats_count); plugin_address_length = ntohs (pi->address_length); plugin_name_length = ntohs (pi->plugin_name_length); - addr_active = ntohl (pi->address_active); + addr_active = (int) ntohl (pi->address_active); atsi = (const struct GNUNET_ATS_Information *) &pi[1]; plugin_address = (const char *) &atsi[ats_count]; plugin_name = &plugin_address[plugin_address_length]; @@ -389,7 +389,6 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph, address.address = plugin_address; address.address_length = plugin_address_length; address.transport_name = plugin_name; - ph->addr_info_cb (ph->addr_info_cb_cls, &address, addr_active, @@ -482,8 +481,9 @@ process_ar_message (struct GNUNET_ATS_PerformanceHandle *ph, GNUNET_break(0); return GNUNET_SYSERR; } - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, _("Received %s message\n"), - "ATS_ADDRESSLIST_RESPONSE"); + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + _("Received %s message\n"), + "ATS_ADDRESSLIST_RESPONSE"); pi = (const struct PeerInformationMessage *) msg; id = ntohl (pi->id); @@ -560,7 +560,8 @@ process_ar_message (struct GNUNET_ATS_PerformanceHandle *ph, * @param msg message received, NULL on timeout or fatal error */ static void -process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg) +process_ats_message (void *cls, + const struct GNUNET_MessageHeader *msg) { struct GNUNET_ATS_PerformanceHandle *ph = cls; @@ -649,7 +650,7 @@ reconnect (struct GNUNET_ATS_PerformanceHandle *ph) * @param cfg configuration to use * @param addr_info_cb callback called when performance characteristics for * an address change - * @param addr_info_cb_cls closure for infocb + * @param addr_info_cb_cls closure for @a addr_info_cb * @return ats performance context */ struct GNUNET_ATS_PerformanceHandle * @@ -778,7 +779,7 @@ GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc) * * @param handle the performance handle to use * @param peer peer idm can be NULL for all peers - * @param all GNUNET_YES to get information about all addresses or GNUNET_NO to + * @param all #GNUNET_YES to get information about all addresses or #GNUNET_NO to * get only address currently used * @param infocb callback to call with the addresses, * will callback with address == NULL when done @@ -832,8 +833,9 @@ GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *hand { memset (&m->peer, '\0', sizeof(struct GNUNET_PeerIdentity)); } - GNUNET_CONTAINER_DLL_insert_tail(handle->pending_head, handle->pending_tail, - p); + GNUNET_CONTAINER_DLL_insert_tail(handle->pending_head, + handle->pending_tail, + p); do_transmit (handle); @@ -849,11 +851,11 @@ GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *hand void GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle) { - GNUNET_assert(NULL != handle); - - GNUNET_CONTAINER_DLL_remove(handle->ph->addresslist_head, - handle->ph->addresslist_tail, handle); - GNUNET_free(handle); + GNUNET_assert (NULL != handle); + GNUNET_CONTAINER_DLL_remove (handle->ph->addresslist_head, + handle->ph->addresslist_tail, + handle); + GNUNET_free (handle); } diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index ca8afecd9..93b9514fb 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -336,6 +336,13 @@ struct GAS_Addresses_Handle char *plugin; }; + +/** + * Value we pass for zero bandwidth. + */ +const static struct GNUNET_BANDWIDTH_Value32NBO zero_bw; + + /** * Disassemble ATS information and update performance information in address * @@ -343,23 +350,23 @@ struct GAS_Addresses_Handle * * @param dest destination address * @param update source ATS information - * @param update_count number of ATS information + * @param update_count number of ATS information in @a update * @param delta_dest ats performance information which were updated * including previous value - * @param delta_count number of ATS information in the delta - * @return GNUNET_YES if address was address updated, GNUNET_NO otherwise + * @param delta_count number of ATS information in the @a delta_dest + * @return #GNUNET_YES if address was address updated, GNUNET_NO otherwise */ static unsigned int disassemble_ats_information (struct ATS_Address *dest, - const struct GNUNET_ATS_Information *update, uint32_t update_count, - struct GNUNET_ATS_Information **delta_dest, uint32_t *delta_count) + const struct GNUNET_ATS_Information *update, + uint32_t update_count, + struct GNUNET_ATS_Information **delta_dest, + uint32_t *delta_count) { - int c1; int c2; int found; int change; - struct GNUNET_ATS_Information add_atsi[update_count]; struct GNUNET_ATS_Information delta_atsi[update_count]; struct GNUNET_ATS_Information *tmp_atsi; @@ -452,6 +459,7 @@ disassemble_ats_information (struct ATS_Address *dest, return change; } + /** * Free the given address * @@ -504,10 +512,13 @@ create_address (const struct GNUNET_PeerIdentity *peer, for (c2 = 0; c2 < GAS_normalization_queue_length; c2++) aa->atsin[c1].atsi_abs[c2] = GNUNET_ATS_VALUE_UNDEFINED; } - return aa; } + +/** + * Closure for #compare_address_it() + */ struct CompareAddressContext { const struct ATS_Address *search; @@ -599,6 +610,7 @@ compare_address_it (void *cls, return GNUNET_NO; /* Stop iteration since we have an exact address */ } + /** * Find an existing equivalent address record. * Compares by peer identity and network address OR by session ID @@ -611,7 +623,8 @@ compare_address_it (void *cls, */ struct ATS_Address * find_equivalent_address (struct GAS_Addresses_Handle *handle, - const struct GNUNET_PeerIdentity *peer, const struct ATS_Address *addr) + const struct GNUNET_PeerIdentity *peer, + const struct ATS_Address *addr) { struct CompareAddressContext cac; @@ -643,29 +656,34 @@ find_equivalent_address (struct GAS_Addresses_Handle *handle, static struct ATS_Address * find_exact_address (struct GAS_Addresses_Handle *handle, - const struct GNUNET_PeerIdentity *peer, - const char *plugin_name, - const void *plugin_addr, - size_t plugin_addr_len, - uint32_t local_address_info, - uint32_t session_id) + const struct GNUNET_PeerIdentity *peer, + const char *plugin_name, + const void *plugin_addr, + size_t plugin_addr_len, + uint32_t local_address_info, + uint32_t session_id) { struct ATS_Address *aa; struct ATS_Address *ea; - aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, - local_address_info, session_id); + aa = create_address (peer, + plugin_name, + plugin_addr, + plugin_addr_len, + local_address_info, + session_id); /* Get existing address or address with session == 0 */ ea = find_equivalent_address (handle, peer, aa); free_address (aa); - if (ea == NULL ) - return NULL ; + if (ea == NULL) + return NULL; else if (ea->session_id != session_id) - return NULL ; + return NULL; return ea; } + /** * Function allowing the solver to obtain normalized preference * values from solver @@ -675,11 +693,13 @@ find_exact_address (struct GAS_Addresses_Handle *handle, * @return array of double values with |GNUNET_ATS_PreferenceCount| elements */ const double * -get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) +get_preferences_cb (void *cls, + const struct GNUNET_PeerIdentity *id) { return GAS_normalization_get_preferences_by_peer (id); } + /** * Function allowing the solver to obtain normalized property * values for an address from solver @@ -694,6 +714,7 @@ get_property_cb (void *cls, const struct ATS_Address *address) return GAS_normalization_get_properties ((struct ATS_Address *) address); } + /** * Extract an ATS performance info from an address * @@ -718,6 +739,7 @@ get_performance_info (struct ATS_Address *address, uint32_t type) return GNUNET_ATS_VALUE_UNDEFINED; } + /** * Add a new address for a peer. * @@ -725,22 +747,22 @@ get_performance_info (struct ATS_Address *address, uint32_t type) * @param peer peer * @param plugin_name transport plugin name * @param plugin_addr plugin address - * @param plugin_addr_len length of the plugin address + * @param plugin_addr_len length of the plugin address in @a plugin_addr * @param local_address_info the local address for the address * @param session_id session id, can be 0 * @param atsi performance information for this address - * @param atsi_count number of performance information contained + * @param atsi_count number of performance information contained in @a atsi */ void GAS_addresses_add (struct GAS_Addresses_Handle *handle, - const struct GNUNET_PeerIdentity *peer, - const char *plugin_name, - const void *plugin_addr, - size_t plugin_addr_len, - uint32_t local_address_info, - uint32_t session_id, - const struct GNUNET_ATS_Information *atsi, - uint32_t atsi_count) + const struct GNUNET_PeerIdentity *peer, + const char *plugin_name, + const void *plugin_addr, + size_t plugin_addr_len, + uint32_t local_address_info, + uint32_t session_id, + const struct GNUNET_ATS_Information *atsi, + uint32_t atsi_count) { struct ATS_Address *new_address; struct ATS_Address *existing_address; @@ -750,16 +772,19 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, uint32_t previous_session; int c1; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received `%s' for peer `%s'\n", - "ADDRESS ADD", GNUNET_i2s (peer)); + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + "Received `%s' for peer `%s'\n", + "ADDRESS ADD", + GNUNET_i2s (peer)); if (GNUNET_NO == handle->running) return; GNUNET_assert(NULL != handle->addresses); - new_address = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, - local_address_info, session_id); + new_address = create_address (peer, plugin_name, + plugin_addr, plugin_addr_len, + local_address_info, session_id); atsi_delta = NULL; disassemble_ats_information (new_address, atsi, atsi_count, &atsi_delta, &atsi_delta_count); @@ -775,11 +800,11 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, /* Add a new address */ new_address->t_added = GNUNET_TIME_absolute_get(); new_address->t_last_activity = GNUNET_TIME_absolute_get(); - GNUNET_assert( - GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (handle->addresses, - peer, - new_address, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); + GNUNET_assert(GNUNET_OK == + GNUNET_CONTAINER_multipeermap_put (handle->addresses, + peer, + new_address, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); GNUNET_STATISTICS_set (handle->stat, "# addresses", @@ -899,6 +924,7 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, session_id, GNUNET_ATS_print_network_type (addr_net)); } + /** * Update an address with a session or performance information for a peer. * @@ -913,7 +939,7 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle, * @param local_address_info the local address for the address * @param session_id session id, can be 0 * @param atsi performance information for this address - * @param atsi_count number of performance information contained + * @param atsi_count number of performance information contained in @a atsi */ void GAS_addresses_update (struct GAS_Addresses_Handle *handle, @@ -1049,10 +1075,11 @@ destroy_by_session_id (void *cls, const struct ATS_Address *des = dc->aa; struct ATS_Address *aa = value; - GNUNET_assert( - 0 == memcmp (&aa->peer, &des->peer, sizeof(struct GNUNET_PeerIdentity))); - - if (des->session_id == 0) + GNUNET_assert(0 == + memcmp (&aa->peer, + &des->peer, + sizeof (struct GNUNET_PeerIdentity))); + if (0 == des->session_id) { /* Session == 0, remove full address */ if ((0 == strcmp (des->plugin, aa->plugin)) @@ -1065,13 +1092,20 @@ destroy_by_session_id (void *cls, GNUNET_i2s (&aa->peer), aa->session_id, aa); - /* Notify solver about deletion */ GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (handle->addresses, &aa->peer, aa)); handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); + GAS_performance_notify_all_clients (&aa->peer, + aa->plugin, + aa->addr, + aa->addr_len, + GNUNET_SYSERR, + NULL, 0, + zero_bw, + zero_bw); free_address (aa); dc->result = GNUNET_NO; return GNUNET_OK; /* Continue iteration */ @@ -1107,6 +1141,14 @@ destroy_by_session_id (void *cls, GNUNET_CONTAINER_multipeermap_remove (handle->addresses, &aa->peer, aa)); handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); + GAS_performance_notify_all_clients (&aa->peer, + aa->plugin, + aa->addr, + aa->addr_len, + GNUNET_SYSERR, + NULL, 0, + zero_bw, + zero_bw); free_address (aa); dc->result = GNUNET_NO; return GNUNET_OK; /* Continue iteration */ @@ -1114,14 +1156,22 @@ destroy_by_session_id (void *cls, else { /* Session died */ - GNUNET_log(GNUNET_ERROR_TYPE_INFO, - "Deleting session for peer `%s': `%s' %u\n", - GNUNET_i2s (&aa->peer), - aa->plugin, aa->session_id); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Deleting session for peer `%s': `%s' %u\n", + GNUNET_i2s (&aa->peer), + aa->plugin, aa->session_id); /* Notify solver to delete session */ handle->env.sf.s_del (handle->solver, aa, GNUNET_YES); aa->session_id = 0; aa->active = GNUNET_NO; + GAS_performance_notify_all_clients (&aa->peer, + aa->plugin, + aa->addr, + aa->addr_len, + GNUNET_NO, + NULL, 0, + zero_bw, + zero_bw); return GNUNET_OK; } } @@ -1136,7 +1186,7 @@ destroy_by_session_id (void *cls, * @param peer peer * @param plugin_name transport plugin name * @param plugin_addr plugin address - * @param plugin_addr_len length of the plugin address + * @param plugin_addr_len length of the plugin address in @a plugin_addr * @param local_address_info the local address for the address * @param session_id session id, can be 0 */ @@ -1156,11 +1206,16 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, return; /* Get existing address */ - ea = find_exact_address (handle, peer, plugin_name, plugin_addr, - plugin_addr_len, local_address_info, session_id); - if (ea == NULL ) + ea = find_exact_address (handle, + peer, + plugin_name, + plugin_addr, + plugin_addr_len, + local_address_info, + session_id); + if (NULL == ea) { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Tried to destroy unknown address for peer `%s' `%s' session id %u\n", GNUNET_i2s (peer), plugin_name, @@ -1168,13 +1223,12 @@ GAS_addresses_destroy (struct GAS_Addresses_Handle *handle, return; } - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Received `%s' for peer `%s' address %p session %u\n", "ADDRESS DESTROY", - GNUNET_i2s (peer), - ea, - session_id); - - GNUNET_break(0 < strlen (plugin_name)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received `%s' for peer `%s' address %p session %u\n", "ADDRESS DESTROY", + GNUNET_i2s (peer), + ea, + session_id); + GNUNET_break (0 < strlen (plugin_name)); dc.handle = handle; dc.aa = create_address (peer, plugin_name, @@ -2037,8 +2091,15 @@ destroy_all_address_it (void *cls, /* Notify */ handle->env.sf.s_del (handle->solver, aa, GNUNET_NO); /* Destroy */ + GAS_performance_notify_all_clients (&aa->peer, + aa->plugin, + aa->addr, + aa->addr_len, + GNUNET_NO, + NULL, 0, + zero_bw, + zero_bw); free_address (aa); - return GNUNET_OK; } @@ -2054,9 +2115,10 @@ GAS_addresses_destroy_all (struct GAS_Addresses_Handle *handle) if (GNUNET_NO == handle->running) return; - GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Destroying all addresses\n"); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Destroying all addresses\n"); handle->env.sf.s_bulk_start (handle->solver); - if (handle->addresses != NULL ) + if (NULL != handle->addresses) GNUNET_CONTAINER_multipeermap_iterate (handle->addresses, &destroy_all_address_it, handle); @@ -2219,24 +2281,25 @@ GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle, void *pi_it_cls) { struct PeerInfoIteratorContext pi_ctx; - struct GNUNET_BANDWIDTH_Value32NBO zero_bw; GNUNET_assert(NULL != peer); GNUNET_assert(NULL != handle->addresses); if (NULL == pi_it) return; /* does not make sense without callback */ - zero_bw = GNUNET_BANDWIDTH_value_init (0); pi_ctx.it = pi_it; pi_ctx.it_cls = pi_it_cls; - GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses, peer, &peerinfo_it, &pi_ctx); if (NULL != pi_it) - pi_it (pi_it_cls, NULL, NULL, NULL, 0, GNUNET_NO, NULL, 0, zero_bw, - zero_bw); + pi_it (pi_it_cls, + NULL, NULL, NULL, 0, + GNUNET_NO, + NULL, 0, + zero_bw, + zero_bw); } diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 2171ba697..16b6404d6 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c @@ -144,9 +144,12 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client) * @param plugin_name 0-termintated string specifying the transport plugin * @param plugin_addr binary address for the plugin to use * @param plugin_addr_len number of bytes in plugin_addr - * @param active is this address active + * @param active #GNUNET_YES if this address is actively used + * to maintain a connection to a peer; + * #GNUNET_NO if the address is not actively used; + * #GNUNET_SYSERR if this address is no longer available for ATS * @param atsi performance data for the address - * @param atsi_count number of performance records in 'ats' + * @param atsi_count number of performance records in @a atsi * @param bandwidth_out assigned outbound bandwidth * @param bandwidth_in assigned inbound bandwidth */ @@ -189,7 +192,7 @@ GAS_performance_notify_client (struct PerformanceClient *pc, msg->ats_count = htonl (atsi_count); msg->peer = *peer; msg->address_length = htons (plugin_addr_len); - msg->address_active = ntohl (active); + msg->address_active = ntohl ((uint32_t) active); msg->plugin_name_length = htons (plugin_name_length); msg->bandwidth_out = bandwidth_out; msg->bandwidth_in = bandwidth_in; @@ -213,7 +216,10 @@ GAS_performance_notify_client (struct PerformanceClient *pc, * @param plugin_name 0-termintated string specifying the transport plugin * @param plugin_addr binary address for the plugin to use * @param plugin_addr_len number of bytes in @a plugin_addr - * @param active is this address active + * @param active #GNUNET_YES if this address is actively used + * to maintain a connection to a peer; + * #GNUNET_NO if the address is not actively used; + * #GNUNET_SYSERR if this address is no longer available for ATS * @param atsi performance data for the address * @param atsi_count number of performance records in @a atsi * @param bandwidth_out assigned outbound bandwidth @@ -259,7 +265,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, * @param plugin_name plugin name * @param plugin_addr address * @param plugin_addr_len length of @a plugin_addr - * @param address_active is address actively used + * @param active is address actively used * @param atsi ats performance information * @param atsi_count number of ats performance elements in @a atsi * @param bandwidth_out current outbound bandwidth assigned to address @@ -269,8 +275,9 @@ static void peerinfo_it (void *cls, const struct GNUNET_PeerIdentity *id, const char *plugin_name, - const void *plugin_addr, size_t plugin_addr_len, - const int active, + const void *plugin_addr, + size_t plugin_addr_len, + int active, const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, @@ -360,7 +367,7 @@ transmit_req_addr (struct AddressIteration *ai, const struct GNUNET_PeerIdentity *id, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, - const int active, + int active, const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, @@ -428,15 +435,14 @@ transmit_req_addr (struct AddressIteration *ai, */ static void req_addr_peerinfo_it (void *cls, - const struct GNUNET_PeerIdentity *id, - const char *plugin_name, - const void *plugin_addr, size_t plugin_addr_len, - const int active, - const struct GNUNET_ATS_Information *atsi, - uint32_t atsi_count, - struct GNUNET_BANDWIDTH_Value32NBO - bandwidth_out, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) + const struct GNUNET_PeerIdentity *id, + const char *plugin_name, + const void *plugin_addr, size_t plugin_addr_len, + int active, + const struct GNUNET_ATS_Information *atsi, + uint32_t atsi_count, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) { struct AddressIteration *ai = cls; @@ -515,7 +521,8 @@ req_addr_peer_it (void *cls, * @param message the request message */ void -GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client, +GAS_handle_request_address_list (void *cls, + struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct PerformanceClient *pc; @@ -568,15 +575,21 @@ void GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, - const int active, + int active, struct GNUNET_ATS_Information *ats, uint32_t ats_count, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) { /* Notify here */ - GAS_performance_notify_all_clients (peer, plugin_name, plugin_addr, - plugin_addr_len, active, ats, ats_count, bandwidth_out, bandwidth_in); + GAS_performance_notify_all_clients (peer, + plugin_name, + plugin_addr, + plugin_addr_len, + active, + ats, ats_count, + bandwidth_out, + bandwidth_in); #if 0 struct PerformanceClient *cur; @@ -617,7 +630,8 @@ GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, * @param message the request message */ void -GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client, +GAS_handle_reservation_request (void *cls, + struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct ReservationRequestMessage *msg = diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h index da4263fe8..e5364e0e5 100644 --- a/src/ats/gnunet-service-ats_performance.h +++ b/src/ats/gnunet-service-ats_performance.h @@ -60,7 +60,7 @@ GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, - const int active, + int active, struct GNUNET_ATS_Information *ats, uint32_t ats_count, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, @@ -75,8 +75,11 @@ GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, * @param peer peer for which this is an address suggestion * @param plugin_name 0-termintated string specifying the transport plugin * @param plugin_addr binary address for the plugin to use - * @param plugin_addr_len number of bytes in plugin_addr - * @param active is this address active + * @param plugin_addr_len number of bytes in @a plugin_addr + * @param active #GNUNET_YES if this address is actively used + * to maintain a connection to a peer; + * #GNUNET_NO if the address is not actively used; + * #GNUNET_SYSERR if this address is no longer available for ATS * @param atsi performance data for the address * @param atsi_count number of performance records in @a atsi * @param bandwidth_out assigned outbound bandwidth @@ -87,7 +90,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, - const int active, + int active, const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, @@ -141,14 +144,14 @@ GAS_handle_preference_change (void *cls, */ void GAS_handle_preference_feedback (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message); + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message); void GAS_handle_monitor (void *cls, - struct GNUNET_SERVER_Client *client, - const struct GNUNET_MessageHeader *message); + struct GNUNET_SERVER_Client *client, + const struct GNUNET_MessageHeader *message); /** * Initialize performance subsystem. diff --git a/src/ats/test_ats_api_performance_list_all_addresses.c b/src/ats/test_ats_api_performance_list_all_addresses.c index 4512739e1..e846d0d43 100644 --- a/src/ats/test_ats_api_performance_list_all_addresses.c +++ b/src/ats/test_ats_api_performance_list_all_addresses.c @@ -103,6 +103,7 @@ ats_perf_cb (void *cls, uint32_t ats_count) { static int counter = 0; + if (NULL == address) { phal = 0; @@ -140,7 +141,7 @@ stat_cb(void *cls, const char *subsystem, "Failed to connect to performance API\n"); GNUNET_SCHEDULER_add_now (end_badly, NULL); } - phal = GNUNET_ATS_performance_list_addresses (perf_ats, NULL, GNUNET_YES, ats_perf_cb, NULL); + phal = GNUNET_ATS_performance_list_addresses (perf_ats, NULL, GNUNET_YES, &ats_perf_cb, NULL); } return GNUNET_OK; } diff --git a/src/ats/test_ats_solver_add_address.c b/src/ats/test_ats_solver_add_address.c index 4cc37e812..0c62d5197 100644 --- a/src/ats/test_ats_solver_add_address.c +++ b/src/ats/test_ats_solver_add_address.c @@ -1,10 +1,4 @@ /* - if (NULL == (perf_ats = GNUNET_ATS_performance_init (cfg, &ats_perf_cb, NULL))) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to connect to performance API\n"); - GNUNET_SCHEDULER_add_now (end_badly, NULL); - } This file is part of GNUnet. (C) 2010-2013 Christian Grothoff (and other contributing authors) 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 8653d7db7..27f34217e 100644 --- a/src/ats/test_ats_solver_alternative_after_delete_address.c +++ b/src/ats/test_ats_solver_alternative_after_delete_address.c @@ -1,10 +1,4 @@ /* - if (NULL == (perf_ats = GNUNET_ATS_performance_init (cfg, &ats_perf_cb, NULL))) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to connect to performance API\n"); - GNUNET_SCHEDULER_add_now (end_badly, NULL); - } This file is part of GNUnet. (C) 2010-2013 Christian Grothoff (and other contributing authors) diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 67db7072b..abade848f 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c @@ -1302,7 +1302,10 @@ handle_direct_disconnect (struct DirectNeighbor *neighbor) * * @param cls closure * @param address the address - * @param active is this address in active use + * @param active #GNUNET_YES if this address is actively used + * to maintain a connection to a peer; + * #GNUNET_NO if the address is not actively used; + * #GNUNET_SYSERR if this address is no longer available for ATS * @param bandwidth_out assigned outbound bandwidth for the connection * @param bandwidth_in assigned inbound bandwidth for the connection * @param ats performance data for the address (as far as known) @@ -1327,8 +1330,11 @@ handle_ats_update (void *cls, return; } - if (GNUNET_NO == active) + if (GNUNET_YES != active) + { + // FIXME: handle disconnect/inactive case too! return; + } distance = get_atsi_distance (ats, ats_count); network = get_atsi_network (ats, ats_count); GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index fd776e7b8..a9be40080 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -261,7 +261,7 @@ update_latencies (void *cls, } if (GNUNET_YES != active) - return; + return; for (i = 0; i < ats_count; i++) { if (GNUNET_ATS_QUALITY_NET_DELAY != ntohl (ats[i].type)) diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index 18c338c2c..c19fa40b6 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h @@ -759,8 +759,10 @@ struct GNUNET_ATS_PerformanceHandle; * * @param cls closure * @param address the address, NULL if ATS service was disconnected - * @param address_active is this address actively used to maintain a connection - to a peer + * @param address_active #GNUNET_YES if this address is actively used + * to maintain a connection to a peer; + * #GNUNET_NO if the address is not actively used; + * #GNUNET_SYSERR if this address is no longer available for ATS * @param bandwidth_out assigned outbound bandwidth for the connection * @param bandwidth_in assigned inbound bandwidth for the connection * @param ats performance data for the address (as far as known) @@ -768,12 +770,13 @@ struct GNUNET_ATS_PerformanceHandle; */ typedef void (*GNUNET_ATS_AddressInformationCallback) (void *cls, - const struct GNUNET_HELLO_Address *address, - int address_active, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, - const struct GNUNET_ATS_Information *ats, - uint32_t ats_count); + const struct GNUNET_HELLO_Address *address, + int address_active, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, + const struct GNUNET_ATS_Information *ats, + uint32_t ats_count); + /** * Handle for an address listing operation @@ -792,10 +795,11 @@ struct GNUNET_ATS_AddressListHandle; */ struct GNUNET_ATS_PerformanceHandle * GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, - GNUNET_ATS_AddressInformationCallback addr_info_cb, + GNUNET_ATS_AddressInformationCallback addr_info_cb, void *addr_info_cb_cls); + /** * Get information about addresses known to the ATS subsystem. * @@ -805,14 +809,15 @@ GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, * get only address currently used * @param infocb callback to call with the addresses, * will callback with address == NULL when done - * @param infocb_cls closure for infocb + * @param infocb_cls closure for @a infocb * @return ats performance context */ struct GNUNET_ATS_AddressListHandle * -GNUNET_ATS_performance_list_addresses ( - struct GNUNET_ATS_PerformanceHandle *handle, - const struct GNUNET_PeerIdentity *peer, int all, - GNUNET_ATS_AddressInformationCallback infocb, void *infocb_cls); +GNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *handle, + const struct GNUNET_PeerIdentity *peer, + int all, + GNUNET_ATS_AddressInformationCallback infocb, + void *infocb_cls); /** @@ -845,8 +850,9 @@ GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph); */ typedef void (*GNUNET_ATS_ReservationCallback) (void *cls, - const struct GNUNET_PeerIdentity * peer, int32_t amount, - struct GNUNET_TIME_Relative res_delay); + const struct GNUNET_PeerIdentity * peer, + int32_t amount, + struct GNUNET_TIME_Relative res_delay); /** diff --git a/src/testbed/gnunet-daemon-latency-logger.c b/src/testbed/gnunet-daemon-latency-logger.c index 774b5dd4d..a33d00e92 100644 --- a/src/testbed/gnunet-daemon-latency-logger.c +++ b/src/testbed/gnunet-daemon-latency-logger.c @@ -21,7 +21,7 @@ /** * @file testbed/gnunet-daemon-latency-logger.c * @brief log latency values from neighbour connections into an SQLite database - * @author Sree Harsha Totakura + * @author Sree Harsha Totakura */ #include "platform.h" @@ -71,7 +71,7 @@ struct Entry * The last known value for latency */ unsigned int latency; - + }; @@ -119,7 +119,7 @@ free_iterator (void *cls, { struct Entry *e = cls; - GNUNET_assert (GNUNET_YES == + GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (map, key, e)); GNUNET_free (e); return GNUNET_YES; @@ -131,7 +131,7 @@ free_iterator (void *cls, * * @param cls NULL * @param tc task context from scheduler - * @return + * @return */ static void do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) @@ -148,7 +148,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) db = NULL; if (NULL != map) { - GNUNET_assert (GNUNET_SYSERR != + GNUNET_assert (GNUNET_SYSERR != GNUNET_CONTAINER_multipeermap_iterate (map, free_iterator, NULL)); GNUNET_CONTAINER_multipeermap_destroy (map); map = NULL; @@ -160,8 +160,10 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * * @param cls closure * @param address the address - * @param address_active is this address actively used to maintain a connection - * to a peer + * @param address_active #GNUNET_YES if this address is actively used + * to maintain a connection to a peer; + * #GNUNET_NO if the address is not actively used; + * #GNUNET_SYSERR if this address is no longer available for ATS * @param bandwidth_out assigned outbound bandwidth for the connection * @param bandwidth_in assigned inbound bandwidth for the connection * @param ats performance data for the address (as far as known) @@ -197,7 +199,7 @@ addr_info_cb (void *cls, } GNUNET_assert (NULL != db); - if (GNUNET_NO == address_active) + if (GNUNET_YES != address_active) return; for (cnt = 0; cnt < ats_count; cnt++) { @@ -248,13 +250,13 @@ addr_info_cb (void *cls, { entry = GNUNET_new (struct Entry); entry->id = address->peer; - GNUNET_CONTAINER_multipeermap_put (map, + GNUNET_CONTAINER_multipeermap_put (map, &entry->id, entry, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); } entry->latency = latency; return; - + err_shutdown: GNUNET_SCHEDULER_shutdown (); } @@ -272,7 +274,7 @@ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { - const char *query_create = + const char *query_create = "CREATE TABLE ats_info (" "id TEXT," "val INTEGER," @@ -303,9 +305,9 @@ run (void *cls, char *const *args, const char *cfgfile, DEBUG ("SQLite Error: %d. Perhaps the database `%s' already exits.\n", sqlite3_errcode (db), dbfile); DEBUG ("Opened database %s\n", dbfile); - GNUNET_free (dbfile); + GNUNET_free (dbfile); dbfile = NULL; - ats = GNUNET_ATS_performance_init (c, addr_info_cb, NULL); + ats = GNUNET_ATS_performance_init (c, &addr_info_cb, NULL); map = GNUNET_CONTAINER_multipeermap_create (30, GNUNET_YES); shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, NULL); -- cgit v1.2.3