From bb720291e7a5a71e9139865f97025bfa179cd3a3 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 18 Jan 2015 17:31:14 +0000 Subject: -remarking on things to fix --- src/transport/gnunet-service-transport.c | 31 +++++++++++++++------- .../gnunet-service-transport_neighbours.c | 14 +++++++--- .../gnunet-service-transport_validation.c | 12 +++++---- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 330382604..01ca2fc67 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -188,6 +188,7 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello) GST_neighbours_iterate (&transmit_our_hello, (void *) hello); } + /** * We received some payload. Prepare to pass it on to our clients. * @@ -211,7 +212,7 @@ process_payload (const struct GNUNET_PeerIdentity *peer, do_forward = GNUNET_SYSERR; ret = GST_neighbours_calculate_receive_delay (peer, msg_size, &do_forward); - if (!GST_neighbours_test_connected (peer)) + if (! GST_neighbours_test_connected (peer)) { GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Discarded %u bytes type %u payload from peer `%s'\n", msg_size, @@ -222,6 +223,7 @@ process_payload (const struct GNUNET_PeerIdentity *peer, return ret; } + // FIXME: why is this call here? GST_ats_add_address (address, session, NULL, 0); if (GNUNET_YES != do_forward) @@ -357,6 +359,7 @@ connect_bl_check_cont (void *cls, GNUNET_free (blctx); } + /** * Black list check result for try_connect call * If connection to the peer is allowed request adddress and @@ -377,7 +380,9 @@ connect_transport_bl_check_cont (void *cls, if (GNUNET_OK == result) { /* Blacklist allows to speak to this transport */ - GST_ats_add_address(blctx->address, blctx->session, blctx->ats, blctx->ats_count); + GST_ats_add_address (blctx->address, + blctx->session, + blctx->ats, blctx->ats_count); } if (NULL != blctx->address) @@ -671,8 +676,9 @@ plugin_env_address_to_type (void *cls, */ void GST_ats_add_address (const struct GNUNET_HELLO_Address *address, - struct Session *session, const struct GNUNET_ATS_Information *ats, - uint32_t ats_count) + struct Session *session, + const struct GNUNET_ATS_Information *ats, + uint32_t ats_count) { struct GNUNET_TRANSPORT_PluginFunctions *papi; struct GNUNET_ATS_Information ats2[ats_count + 1]; @@ -710,14 +716,19 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address, ats2[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); ats2[0].value = htonl (net); memcpy (&ats2[1], ats, sizeof(struct GNUNET_ATS_Information) * ats_count); - GNUNET_log(GNUNET_ERROR_TYPE_INFO, - "Notifying ATS about peer `%s''s new address `%s' session %p in network %s\n", - GNUNET_i2s (&address->peer), - (0 == address->address_length) ? "" : GST_plugins_a2s (address), - session, GNUNET_ATS_print_network_type (net)); - GNUNET_ATS_address_add (GST_ats, address, session, ats2, ats_count + 1); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Notifying ATS about peer `%s''s new address `%s' session %p in network %s\n", + GNUNET_i2s (&address->peer), + (0 == address->address_length) + ? "" + : GST_plugins_a2s (address), + session, + GNUNET_ATS_print_network_type (net)); + GNUNET_ATS_address_add (GST_ats, address, session, + ats2, ats_count + 1); } + /** * Notify ATS about property changes to an address * diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 748d88f1f..1bf1fd754 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -3161,6 +3161,8 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag n->primary_address.bandwidth_in, n->primary_address.bandwidth_out); /* Tell ATS that the outbound session we created to send SYN was successful */ + // FIXME: shouldn't ATS already know about *outbound* sessions + // in particular? GST_ats_add_address (n->primary_address.address, n->primary_address.session, NULL, 0); @@ -3204,6 +3206,7 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag GNUNET_break (GNUNET_NO == n->alternative_address.ats_active); /* Notify about session... perhaps we obtained it */ + // FIXME: why is this needed? GST_ats_add_address (n->alternative_address.address, n->alternative_address.session, NULL, 0); /* Set primary addresses */ @@ -3444,8 +3447,8 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, now wait for the ACK to finally be connected - If we sent a SYN_ACK to this peer before */ - if ( (GNUNET_TRANSPORT_PS_SYN_RECV_ACK != n->state) && - (ACK_SEND_ACK != n->ack_state)) + if ( (GNUNET_TRANSPORT_PS_SYN_RECV_ACK != n->state) && + (ACK_SEND_ACK != n->ack_state)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Received unexpected ACK message from peer `%s' in state %s/%s\n", @@ -3486,8 +3489,10 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, /* Add session to ATS since no session was given (NULL) and we may have * obtained a new session */ - GST_ats_add_address (n->primary_address.address, n->primary_address.session, - NULL, 0); + // FIXME: likely not the best place to do this... + GST_ats_add_address (n->primary_address.address, + n->primary_address.session, + NULL, 0); /* Set primary address to used */ set_primary_address (n, @@ -3512,6 +3517,7 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target) return test_connected (lookup_neighbour (target)); } + /** * Change the incoming quota for the given peer. * diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index e7ede0b07..b02c90009 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -833,13 +833,13 @@ add_valid_address (void *cls, } ve = find_validation_entry (&public_key, address); - ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); - + ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, + expiration); if (NULL == ve->revalidation_task) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting revalidations for valid address `%s'\n", - GST_plugins_a2s (ve->address)); + GST_plugins_a2s (ve->address)); ve->next_validation = GNUNET_TIME_absolute_get(); ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); } @@ -1417,8 +1417,9 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, GNUNET_break_op (0); return GNUNET_SYSERR; } - if (GNUNET_TIME_absolute_get_remaining - (GNUNET_TIME_absolute_ntoh (pong->expiration)).rel_value_us == 0) + if (0 == + GNUNET_TIME_absolute_get_remaining + (GNUNET_TIME_absolute_ntoh (pong->expiration)).rel_value_us) { GNUNET_STATISTICS_update (GST_stats, gettext_noop @@ -1490,6 +1491,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, ats[0].value = htonl ((uint32_t) ve->latency.rel_value_us); ats[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); ats[1].value = htonl ((uint32_t) ve->network); + // FIXME: add vs. update! GNUNET_ATS_address_add (GST_ats, ve->address, NULL, ats, 2); } if (validations_running > 0) -- cgit v1.2.3