diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-19 09:55:56 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-19 09:55:56 +0000 |
commit | 994db2fb30217f25b1e4aaf207270cdcc4320ce6 (patch) | |
tree | 3a231a6eb5b0000d4b09f60ad35d98dbceae677c /src/transport/gnunet-service-transport_neighbours.c | |
parent | 36a3ceafd059b7473cf63ae26d6e332bf3a9ef45 (diff) | |
download | gnunet-994db2fb30217f25b1e4aaf207270cdcc4320ce6.tar.gz gnunet-994db2fb30217f25b1e4aaf207270cdcc4320ce6.zip |
changes to connect behabviour and a lot iof improved debug messages
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index f0a4b3d63..6636cc29b 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -608,9 +608,9 @@ set_state (struct NeighbourMapEntry *n, enum GNUNET_TRANSPORT_PeerState s) | |||
608 | n->state, n->timeout, | 608 | n->state, n->timeout, |
609 | n->primary_address.bandwidth_in, | 609 | n->primary_address.bandwidth_in, |
610 | n->primary_address.bandwidth_out); | 610 | n->primary_address.bandwidth_out); |
611 | |||
612 | } | 611 | } |
613 | 612 | ||
613 | |||
614 | /** | 614 | /** |
615 | * Set net state and state timeout for this neighbour and notify monitoring | 615 | * Set net state and state timeout for this neighbour and notify monitoring |
616 | * | 616 | * |
@@ -858,9 +858,7 @@ free_neighbour (struct NeighbourMapEntry *n, | |||
858 | set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED); | 858 | set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED); |
859 | 859 | ||
860 | if (NULL != n->primary_address.address) | 860 | if (NULL != n->primary_address.address) |
861 | { | ||
862 | backup_primary = GNUNET_HELLO_address_copy (n->primary_address.address); | 861 | backup_primary = GNUNET_HELLO_address_copy (n->primary_address.address); |
863 | } | ||
864 | else | 862 | else |
865 | backup_primary = NULL; | 863 | backup_primary = NULL; |
866 | 864 | ||
@@ -868,33 +866,26 @@ free_neighbour (struct NeighbourMapEntry *n, | |||
868 | free_address (&n->primary_address); | 866 | free_address (&n->primary_address); |
869 | free_address (&n->alternative_address); | 867 | free_address (&n->alternative_address); |
870 | 868 | ||
871 | /* FIXME: Note that if we are switching between two TCP sessions to | 869 | /* cut all transport-level connection for this peer */ |
872 | the same peer, we might want to selectively kill only one of | ||
873 | them! Killing all sessions like this seems to be very, very | ||
874 | wrong. */ | ||
875 | |||
876 | /* cut transport-level connection */ | ||
877 | if ((GNUNET_NO == keep_sessions) && | 870 | if ((GNUNET_NO == keep_sessions) && |
878 | (NULL != backup_primary) && | 871 | (NULL != backup_primary) && |
879 | (NULL != (papi = GST_plugins_find (backup_primary->transport_name)))) | 872 | (NULL != (papi = GST_plugins_find (backup_primary->transport_name)))) |
880 | papi->disconnect_peer (papi->cls, &n->id); | 873 | papi->disconnect_peer (papi->cls, &n->id); |
881 | 874 | ||
882 | GNUNET_free_non_null (backup_primary); | 875 | if (NULL != backup_primary) |
883 | 876 | GNUNET_HELLO_address_free (backup_primary); | |
884 | GNUNET_assert (GNUNET_YES == | 877 | GNUNET_assert (GNUNET_YES == |
885 | GNUNET_CONTAINER_multipeermap_remove (neighbours, | 878 | GNUNET_CONTAINER_multipeermap_remove (neighbours, |
886 | &n->id, n)); | 879 | &n->id, n)); |
887 | 880 | ||
888 | // FIXME-ATS-API: we might want to be more specific about | 881 | /* Cancel address requests for this peer */ |
889 | // which states we do this from in the future (ATS should | ||
890 | // have given us a 'suggest_address' handle, and if we have | ||
891 | // such a handle, we should cancel the operation here! | ||
892 | if (NULL != n->suggest_handle) | 882 | if (NULL != n->suggest_handle) |
893 | { | 883 | { |
894 | GNUNET_ATS_suggest_address_cancel (GST_ats, &n->id); | 884 | GNUNET_ATS_suggest_address_cancel (GST_ats, &n->id); |
895 | n->suggest_handle = NULL; | 885 | n->suggest_handle = NULL; |
896 | } | 886 | } |
897 | 887 | ||
888 | /* Cancel the master task */ | ||
898 | if (GNUNET_SCHEDULER_NO_TASK != n->task) | 889 | if (GNUNET_SCHEDULER_NO_TASK != n->task) |
899 | { | 890 | { |
900 | GNUNET_SCHEDULER_cancel (n->task); | 891 | GNUNET_SCHEDULER_cancel (n->task); |
@@ -1604,6 +1595,7 @@ send_session_connect (struct NeighbourAddress *na) | |||
1604 | { | 1595 | { |
1605 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 1596 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
1606 | struct SessionConnectMessage connect_msg; | 1597 | struct SessionConnectMessage connect_msg; |
1598 | struct NeighbourMapEntry *n; | ||
1607 | 1599 | ||
1608 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1600 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1609 | "Sending SESSION_CONNECT message to peer %s\n", | 1601 | "Sending SESSION_CONNECT message to peer %s\n", |
@@ -1640,7 +1632,24 @@ send_session_connect (struct NeighbourAddress *na) | |||
1640 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1632 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1641 | _("Failed to transmit CONNECT message via plugin to %s\n"), | 1633 | _("Failed to transmit CONNECT message via plugin to %s\n"), |
1642 | GST_plugins_a2s (na->address)); | 1634 | GST_plugins_a2s (na->address)); |
1635 | |||
1636 | n = lookup_neighbour (&na->address->peer); | ||
1637 | if (NULL == n) | ||
1638 | { | ||
1639 | GNUNET_break (0); | ||
1640 | return; | ||
1641 | } | ||
1642 | /* Hard failure to send the CONNECT message with this address: | ||
1643 | Destroy address and session */ | ||
1644 | GNUNET_ATS_address_destroyed (GST_ats, na->address, na->session); | ||
1645 | GNUNET_ATS_address_destroyed (GST_ats, na->address, NULL); | ||
1646 | |||
1647 | /* Remove address and request and additional one */ | ||
1648 | /* TODO */ | ||
1649 | |||
1650 | return; | ||
1643 | } | 1651 | } |
1652 | |||
1644 | GST_neighbours_notify_data_sent (&na->address->peer, | 1653 | GST_neighbours_notify_data_sent (&na->address->peer, |
1645 | na->address, | 1654 | na->address, |
1646 | na->session, | 1655 | na->session, |
@@ -1974,10 +1983,13 @@ try_connect_bl_check_cont (void *cls, | |||
1974 | GNUNET_i2s (peer)); | 1983 | GNUNET_i2s (peer)); |
1975 | return; | 1984 | return; |
1976 | } | 1985 | } |
1986 | |||
1987 | /* Setup a new neighbour */ | ||
1977 | n = setup_neighbour (peer); | 1988 | n = setup_neighbour (peer); |
1989 | |||
1990 | /* Request address suggestions for this peer */ | ||
1978 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, | 1991 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, |
1979 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 1992 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); |
1980 | |||
1981 | GNUNET_ATS_reset_backoff (GST_ats, peer); | 1993 | GNUNET_ATS_reset_backoff (GST_ats, peer); |
1982 | n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer, | 1994 | n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer, |
1983 | &address_suggest_cont, n); | 1995 | &address_suggest_cont, n); |
@@ -2154,6 +2166,7 @@ handle_test_blacklist_cont (void *cls, | |||
2154 | else | 2166 | else |
2155 | { | 2167 | { |
2156 | free_address (&n->primary_address); | 2168 | free_address (&n->primary_address); |
2169 | GNUNET_break (0); | ||
2157 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, | 2170 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, |
2158 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 2171 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); |
2159 | } | 2172 | } |
@@ -2519,9 +2532,17 @@ switch_address_bl_check_cont (void *cls, | |||
2519 | blc_ctx->session, | 2532 | blc_ctx->session, |
2520 | GNUNET_i2s (&blc_ctx->address->peer)); | 2533 | GNUNET_i2s (&blc_ctx->address->peer)); |
2521 | } | 2534 | } |
2522 | /* Delete address (or session if existing) in ATS */ | 2535 | |
2536 | /* This address is blacklisted, delete address and session (if existing) in ATS */ | ||
2523 | GNUNET_ATS_address_destroyed (GST_ats, blc_ctx->address, blc_ctx->session); | 2537 | GNUNET_ATS_address_destroyed (GST_ats, blc_ctx->address, blc_ctx->session); |
2524 | 2538 | ||
2539 | if ( (GNUNET_YES == (GNUNET_HELLO_address_check_option (blc_ctx->address, | ||
2540 | GNUNET_HELLO_ADDRESS_INFO_INBOUND))) && (NULL != blc_ctx->session)) | ||
2541 | { | ||
2542 | /* This is an inbound address, destroy full address */ | ||
2543 | GNUNET_ATS_address_destroyed (GST_ats, blc_ctx->address, NULL ); | ||
2544 | } | ||
2545 | |||
2525 | /* Remove blacklist check and clean up */ | 2546 | /* Remove blacklist check and clean up */ |
2526 | GNUNET_CONTAINER_DLL_remove (pending_bc_head, pending_bc_tail, blc_ctx); | 2547 | GNUNET_CONTAINER_DLL_remove (pending_bc_head, pending_bc_tail, blc_ctx); |
2527 | GNUNET_HELLO_address_free (blc_ctx->address); | 2548 | GNUNET_HELLO_address_free (blc_ctx->address); |
@@ -3380,6 +3401,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
3380 | } | 3401 | } |
3381 | 3402 | ||
3382 | n->expect_latency_response = GNUNET_NO; | 3403 | n->expect_latency_response = GNUNET_NO; |
3404 | /* The session for neighbour's primary address died */ | ||
3383 | switch (n->state) | 3405 | switch (n->state) |
3384 | { | 3406 | { |
3385 | case GNUNET_TRANSPORT_PS_NOT_CONNECTED: | 3407 | case GNUNET_TRANSPORT_PS_NOT_CONNECTED: |
@@ -3392,8 +3414,16 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
3392 | return GNUNET_YES; | 3414 | return GNUNET_YES; |
3393 | case GNUNET_TRANSPORT_PS_INIT_BLACKLIST: | 3415 | case GNUNET_TRANSPORT_PS_INIT_BLACKLIST: |
3394 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: | 3416 | case GNUNET_TRANSPORT_PS_CONNECT_SENT: |
3417 | /* The session used to send the CONNECT terminated: | ||
3418 | * this implies a connect error*/ | ||
3419 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
3420 | "Could not send CONNECT message with address `%s' session %p: session terminated, requesting new address\n", | ||
3421 | GST_plugins_a2s (n->primary_address.address), n->primary_address.session, | ||
3422 | GNUNET_i2s (peer)); | ||
3423 | GNUNET_ATS_address_destroyed (GST_ats, n->primary_address.address, NULL); | ||
3395 | free_address (&n->primary_address); | 3424 | free_address (&n->primary_address); |
3396 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 3425 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_INIT_ATS, |
3426 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | ||
3397 | break; | 3427 | break; |
3398 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND: | 3428 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_BLACKLIST_INBOUND: |
3399 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: | 3429 | case GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS: |
@@ -3404,7 +3434,8 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
3404 | free_neighbour (n, GNUNET_NO); | 3434 | free_neighbour (n, GNUNET_NO); |
3405 | return GNUNET_YES; | 3435 | return GNUNET_YES; |
3406 | case GNUNET_TRANSPORT_PS_CONNECTED: | 3436 | case GNUNET_TRANSPORT_PS_CONNECTED: |
3407 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | 3437 | set_state_and_timeout (n, GNUNET_TRANSPORT_PS_RECONNECT_ATS, |
3438 | GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); | ||
3408 | free_address (&n->primary_address); | 3439 | free_address (&n->primary_address); |
3409 | break; | 3440 | break; |
3410 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: | 3441 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: |