diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-28 16:41:42 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-28 16:41:42 +0000 |
commit | f44ded605090e7ed31dd1a25b439139b2bdf59f3 (patch) | |
tree | 4e8ac7e059f72e33ef008b49b6aa5076d174e41f /src/transport/gnunet-service-transport_neighbours.c | |
parent | bfa96bbe8cc79655a3e5611d1bbcaf47ccae6f2a (diff) | |
download | gnunet-f44ded605090e7ed31dd1a25b439139b2bdf59f3.tar.gz gnunet-f44ded605090e7ed31dd1a25b439139b2bdf59f3.zip |
changes to switch when connected
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index ac4a44658..e88173b44 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -1701,6 +1701,8 @@ send_session_connect_cont (void *cls, | |||
1701 | break; | 1701 | break; |
1702 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: | 1702 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: |
1703 | /* Remove address and request and go back to primary address */ | 1703 | /* Remove address and request and go back to primary address */ |
1704 | GNUNET_STATISTICS_update (GST_stats, gettext_noop | ||
1705 | ("# Failed attempts to switch addresses (failed to send CONNECT CONT)"), 1, GNUNET_NO); | ||
1704 | GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address, | 1706 | GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address, |
1705 | n->alternative_address.session); | 1707 | n->alternative_address.session); |
1706 | GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address, | 1708 | GNUNET_ATS_address_destroyed (GST_ats, n->alternative_address.address, |
@@ -1788,6 +1790,8 @@ send_session_connect (struct NeighbourAddress *na) | |||
1788 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 1790 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); |
1789 | break; | 1791 | break; |
1790 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: | 1792 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: |
1793 | GNUNET_STATISTICS_update (GST_stats, gettext_noop | ||
1794 | ("# Failed attempts to switch addresses (failed to send CONNECT)"), 1, GNUNET_NO); | ||
1791 | /* Remove address and request and additional one */ | 1795 | /* Remove address and request and additional one */ |
1792 | unset_alternative_address (n); | 1796 | unset_alternative_address (n); |
1793 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, | 1797 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED, |
@@ -2580,6 +2584,8 @@ switch_address_bl_check_cont (void *cls, | |||
2580 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out); | 2584 | blc_ctx->bandwidth_in, blc_ctx->bandwidth_out); |
2581 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT, | 2585 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT, |
2582 | GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); | 2586 | GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); |
2587 | GNUNET_STATISTICS_update (GST_stats, gettext_noop | ||
2588 | ("# Attempts to switch addresses"), 1, GNUNET_NO); | ||
2583 | send_session_connect (&n->alternative_address); | 2589 | send_session_connect (&n->alternative_address); |
2584 | break; | 2590 | break; |
2585 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: | 2591 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: |
@@ -2606,7 +2612,8 @@ switch_address_bl_check_cont (void *cls, | |||
2606 | send_session_connect (&n->primary_address); | 2612 | send_session_connect (&n->primary_address); |
2607 | break; | 2613 | break; |
2608 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: | 2614 | case GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT: |
2609 | if (n->primary_address.session == blc_ctx->session) | 2615 | if ( (0 == GNUNET_HELLO_address_cmp(n->primary_address.address, |
2616 | blc_ctx->address) && n->primary_address.session == blc_ctx->session) ) | ||
2610 | { | 2617 | { |
2611 | /* ATS switches back to still-active session */ | 2618 | /* ATS switches back to still-active session */ |
2612 | free_address (&n->alternative_address); | 2619 | free_address (&n->alternative_address); |
@@ -3000,6 +3007,8 @@ master_task (void *cls, | |||
3000 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3007 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3001 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to CONNECT on alternative address)\n", | 3008 | "Connection to `%s' timed out, missing KEEPALIVE_RESPONSEs (after trying to CONNECT on alternative address)\n", |
3002 | GNUNET_i2s (&n->id)); | 3009 | GNUNET_i2s (&n->id)); |
3010 | GNUNET_STATISTICS_update (GST_stats, gettext_noop | ||
3011 | ("# Failed attempts to switch addresses (no response)"), 1, GNUNET_NO); | ||
3003 | disconnect_neighbour (n); | 3012 | disconnect_neighbour (n); |
3004 | return; | 3013 | return; |
3005 | } | 3014 | } |
@@ -3178,13 +3187,17 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
3178 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); | 3187 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); |
3179 | GNUNET_break (GNUNET_NO == n->alternative_address.ats_active); | 3188 | GNUNET_break (GNUNET_NO == n->alternative_address.ats_active); |
3180 | 3189 | ||
3190 | /* Notify about session... perhaps we obtained it */ | ||
3181 | GST_ats_add_address (n->alternative_address.address, | 3191 | GST_ats_add_address (n->alternative_address.address, |
3182 | n->alternative_address.session, | 3192 | n->alternative_address.session, NULL, 0); |
3183 | NULL, 0); | 3193 | /* Set primary addresses */ |
3184 | set_primary_address (n, n->alternative_address.address, | 3194 | set_primary_address (n, n->alternative_address.address, |
3185 | n->alternative_address.session, n->alternative_address.bandwidth_in, | 3195 | n->alternative_address.session, n->alternative_address.bandwidth_in, |
3186 | n->alternative_address.bandwidth_out, GNUNET_YES); | 3196 | n->alternative_address.bandwidth_out, GNUNET_YES); |
3187 | 3197 | ||
3198 | GNUNET_STATISTICS_update (GST_stats, gettext_noop | ||
3199 | ("# Successful attempts to switch addresses"), 1, GNUNET_NO); | ||
3200 | |||
3188 | free_address (&n->alternative_address); | 3201 | free_address (&n->alternative_address); |
3189 | send_session_ack_message (n); | 3202 | send_session_ack_message (n); |
3190 | break; | 3203 | break; |
@@ -3250,8 +3263,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
3250 | if ( (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT == n->state) ) | 3263 | if ( (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT == n->state) ) |
3251 | set_state (n, GNUNET_TRANSPORT_PS_CONNECTED); | 3264 | set_state (n, GNUNET_TRANSPORT_PS_CONNECTED); |
3252 | else | 3265 | else |
3253 | GNUNET_break (0); | 3266 | free_address (&n->alternative_address); |
3254 | free_address (&n->alternative_address); | ||
3255 | } | 3267 | } |
3256 | return GNUNET_NO; /* doesn't affect us further */ | 3268 | return GNUNET_NO; /* doesn't affect us further */ |
3257 | } | 3269 | } |
@@ -3318,12 +3330,14 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
3318 | /* primary went down while we were waiting for CONNECT_ACK on secondary; | 3330 | /* primary went down while we were waiting for CONNECT_ACK on secondary; |
3319 | secondary as primary */ | 3331 | secondary as primary */ |
3320 | 3332 | ||
3321 | /* Destroy the address since it cannot be used */ | 3333 | /* Destroy the inbound address since it cannot be used */ |
3322 | GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL); | 3334 | if (GNUNET_YES |
3335 | == GNUNET_HELLO_address_check_option (n->primary_address.address, | ||
3336 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) | ||
3337 | GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL); | ||
3323 | free_address (&n->primary_address); | 3338 | free_address (&n->primary_address); |
3324 | n->primary_address = n->alternative_address; | 3339 | n->primary_address = n->alternative_address; |
3325 | memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress)); | 3340 | memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress)); |
3326 | /* FIXME: Why GNUNET_TRANSPORT_PS_RECONNECT_ATS ?*/ | ||
3327 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, | 3341 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, |
3328 | GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); | 3342 | GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); |
3329 | break; | 3343 | break; |