aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-09 20:56:56 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-09 20:56:56 +0000
commit33610083c32bf0eac960dc274b5178e9643eb0c9 (patch)
tree98bee41670abf4ddd17de1e36c6032d0c828565c /src
parent317f52f9b558f4df29cc0d422b01b856668d57e3 (diff)
downloadgnunet-33610083c32bf0eac960dc274b5178e9643eb0c9.tar.gz
gnunet-33610083c32bf0eac960dc274b5178e9643eb0c9.zip
-eliminate dead argument, do use quota immediately
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport.c4
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c81
2 files changed, 34 insertions, 51 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 65519914a..fcd2a492d 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -895,7 +895,9 @@ ats_request_address_change (void *cls,
895 /* ATS service died, all suggestions become invalid! 895 /* ATS service died, all suggestions become invalid!
896 (but we'll keep using the allocations for a little 896 (but we'll keep using the allocations for a little
897 while, to keep going while ATS restarts) */ 897 while, to keep going while ATS restarts) */
898 // FIXME: do something? 898 /* FIXME: We should drop all
899 connections now, as ATS won't explicitly tell
900 us and be unaware of ongoing resource allocations! */
899 return; 901 return;
900 } 902 }
901 /* ATS tells me to disconnect from peer */ 903 /* ATS tells me to disconnect from peer */
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index f3f9dc3b0..a35100058 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -839,37 +839,29 @@ set_alternative_address (struct NeighbourMapEntry *n,
839 * address must be setup) 839 * address must be setup)
840 * @param bandwidth_in inbound quota to be used when connection is up 840 * @param bandwidth_in inbound quota to be used when connection is up
841 * @param bandwidth_out outbound quota to be used when connection is up 841 * @param bandwidth_out outbound quota to be used when connection is up
842 * @param is_active #GNUNET_YES to mark this as the active address with ATS
843 */ 842 */
844static void 843static void
845set_primary_address (struct NeighbourMapEntry *n, 844set_primary_address (struct NeighbourMapEntry *n,
846 const struct GNUNET_HELLO_Address *address, 845 const struct GNUNET_HELLO_Address *address,
847 struct Session *session, 846 struct Session *session,
848 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 847 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
849 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 848 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
850 int is_active)
851{ 849{
852 if (session == n->primary_address.session) 850 if (session == n->primary_address.session)
853 { 851 {
854 if (is_active != n->primary_address.ats_active) 852 GST_validation_set_address_use (n->primary_address.address,
853 GNUNET_YES);
854 if (n->primary_address.bandwidth_in.value__ != bandwidth_in.value__)
855 { 855 {
856 n->primary_address.ats_active = is_active; 856 n->primary_address.bandwidth_in = bandwidth_in;
857 GST_validation_set_address_use (n->primary_address.address, 857 GST_neighbours_set_incoming_quota (&address->peer,
858 is_active); 858 bandwidth_in);
859 } 859 }
860 if (GNUNET_YES == is_active) 860 if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__)
861 { 861 {
862 if (n->primary_address.bandwidth_in.value__ != bandwidth_in.value__) 862 n->primary_address.bandwidth_out = bandwidth_out;
863 { 863 send_outbound_quota (&address->peer,
864 n->primary_address.bandwidth_in = bandwidth_in; 864 bandwidth_out);
865 GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in);
866 }
867 if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__)
868 {
869 n->primary_address.bandwidth_out = bandwidth_out;
870 send_outbound_quota (&address->peer,
871 bandwidth_out);
872 }
873 } 865 }
874 return; 866 return;
875 } 867 }
@@ -897,18 +889,14 @@ set_primary_address (struct NeighbourMapEntry *n,
897 n->primary_address.bandwidth_in = bandwidth_in; 889 n->primary_address.bandwidth_in = bandwidth_in;
898 n->primary_address.bandwidth_out = bandwidth_out; 890 n->primary_address.bandwidth_out = bandwidth_out;
899 n->primary_address.session = session; 891 n->primary_address.session = session;
900 n->primary_address.ats_active = is_active;
901 n->primary_address.keep_alive_nonce = 0; 892 n->primary_address.keep_alive_nonce = 0;
902 if (GNUNET_YES == is_active) 893 /* subsystems about address use */
903 { 894 GST_validation_set_address_use (n->primary_address.address,
904 /* subsystems about address use */ 895 GNUNET_YES);
905 GST_validation_set_address_use (n->primary_address.address, 896 GST_neighbours_set_incoming_quota (&address->peer,
906 GNUNET_YES); 897 bandwidth_in);
907 GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in); 898 send_outbound_quota (&address->peer,
908 send_outbound_quota (&address->peer, 899 bandwidth_out);
909 bandwidth_out);
910 }
911
912 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 900 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
913 "Neighbour `%s' switched to address `%s'\n", 901 "Neighbour `%s' switched to address `%s'\n",
914 GNUNET_i2s (&n->id), 902 GNUNET_i2s (&n->id),
@@ -2559,8 +2547,7 @@ switch_address_bl_check_cont (void *cls,
2559 blc_ctx->address, 2547 blc_ctx->address,
2560 blc_ctx->session, 2548 blc_ctx->session,
2561 blc_ctx->bandwidth_in, 2549 blc_ctx->bandwidth_in,
2562 blc_ctx->bandwidth_out, 2550 blc_ctx->bandwidth_out);
2563 GNUNET_NO);
2564 if (ACK_SEND_SYN_ACK == n->ack_state) 2551 if (ACK_SEND_SYN_ACK == n->ack_state)
2565 { 2552 {
2566 /* Send pending SYN_ACK message */ 2553 /* Send pending SYN_ACK message */
@@ -2581,8 +2568,7 @@ switch_address_bl_check_cont (void *cls,
2581 blc_ctx->address, 2568 blc_ctx->address,
2582 blc_ctx->session, 2569 blc_ctx->session,
2583 blc_ctx->bandwidth_in, 2570 blc_ctx->bandwidth_in,
2584 blc_ctx->bandwidth_out, 2571 blc_ctx->bandwidth_out);
2585 GNUNET_NO);
2586 if (ACK_SEND_SYN_ACK == n->ack_state) 2572 if (ACK_SEND_SYN_ACK == n->ack_state)
2587 { 2573 {
2588 /* Send pending SYN_ACK message */ 2574 /* Send pending SYN_ACK message */
@@ -2602,8 +2588,7 @@ switch_address_bl_check_cont (void *cls,
2602 blc_ctx->address, 2588 blc_ctx->address,
2603 blc_ctx->session, 2589 blc_ctx->session,
2604 blc_ctx->bandwidth_in, 2590 blc_ctx->bandwidth_in,
2605 blc_ctx->bandwidth_out, 2591 blc_ctx->bandwidth_out);
2606 GNUNET_NO);
2607 /* Send an ACK message as a response to the SYN msg */ 2592 /* Send an ACK message as a response to the SYN msg */
2608 set_state_and_timeout (n, 2593 set_state_and_timeout (n,
2609 GNUNET_TRANSPORT_PS_SYN_RECV_ACK, 2594 GNUNET_TRANSPORT_PS_SYN_RECV_ACK,
@@ -2627,8 +2612,7 @@ switch_address_bl_check_cont (void *cls,
2627 blc_ctx->address, 2612 blc_ctx->address,
2628 blc_ctx->session, 2613 blc_ctx->session,
2629 blc_ctx->bandwidth_in, 2614 blc_ctx->bandwidth_in,
2630 blc_ctx->bandwidth_out, 2615 blc_ctx->bandwidth_out);
2631 GNUNET_NO);
2632 set_state_and_timeout (n, 2616 set_state_and_timeout (n,
2633 GNUNET_TRANSPORT_PS_SYN_RECV_ACK, 2617 GNUNET_TRANSPORT_PS_SYN_RECV_ACK,
2634 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT)); 2618 GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT));
@@ -2658,8 +2642,7 @@ switch_address_bl_check_cont (void *cls,
2658 blc_ctx->address, 2642 blc_ctx->address,
2659 blc_ctx->session, 2643 blc_ctx->session,
2660 blc_ctx->bandwidth_in, 2644 blc_ctx->bandwidth_in,
2661 blc_ctx->bandwidth_out, 2645 blc_ctx->bandwidth_out);
2662 GNUNET_NO);
2663 if (ACK_SEND_SYN_ACK == n->ack_state) 2646 if (ACK_SEND_SYN_ACK == n->ack_state)
2664 { 2647 {
2665 /* Send pending SYN_ACK message */ 2648 /* Send pending SYN_ACK message */
@@ -2679,8 +2662,7 @@ switch_address_bl_check_cont (void *cls,
2679 blc_ctx->address, 2662 blc_ctx->address,
2680 blc_ctx->session, 2663 blc_ctx->session,
2681 blc_ctx->bandwidth_in, 2664 blc_ctx->bandwidth_in,
2682 blc_ctx->bandwidth_out, 2665 blc_ctx->bandwidth_out);
2683 GNUNET_NO);
2684 set_state_and_timeout (n, 2666 set_state_and_timeout (n,
2685 GNUNET_TRANSPORT_PS_RECONNECT_SENT, 2667 GNUNET_TRANSPORT_PS_RECONNECT_SENT,
2686 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT)); 2668 GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT));
@@ -2792,9 +2774,11 @@ GST_neighbours_switch_to_address (const struct GNUNET_HELLO_Address *address,
2792 } 2774 }
2793 2775
2794 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2776 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2795 "ATS suggests address '%s' for peer `%s'\n", 2777 "ATS suggests address '%s' for peer `%s' at %u/%u speed\n",
2796 GST_plugins_a2s (address), 2778 GST_plugins_a2s (address),
2797 GNUNET_i2s (&address->peer)); 2779 GNUNET_i2s (&address->peer),
2780 (unsigned int) ntohl (bandwidth_in.value__),
2781 (unsigned int) ntohl (bandwidth_out.value__));
2798 2782
2799 /* Perform blacklist check */ 2783 /* Perform blacklist check */
2800 blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext); 2784 blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext);
@@ -3184,8 +3168,7 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag
3184 n->primary_address.address, 3168 n->primary_address.address,
3185 n->primary_address.session, 3169 n->primary_address.session,
3186 n->primary_address.bandwidth_in, 3170 n->primary_address.bandwidth_in,
3187 n->primary_address.bandwidth_out, 3171 n->primary_address.bandwidth_out);
3188 GNUNET_YES);
3189 send_session_ack_message (n); 3172 send_session_ack_message (n);
3190 break; 3173 break;
3191 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS: 3174 case GNUNET_TRANSPORT_PS_SYN_RECV_ATS:
@@ -3226,8 +3209,7 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag
3226 n->alternative_address.address, 3209 n->alternative_address.address,
3227 n->alternative_address.session, 3210 n->alternative_address.session,
3228 n->alternative_address.bandwidth_in, 3211 n->alternative_address.bandwidth_in,
3229 n->alternative_address.bandwidth_out, 3212 n->alternative_address.bandwidth_out);
3230 GNUNET_YES);
3231 GNUNET_STATISTICS_update (GST_stats, 3213 GNUNET_STATISTICS_update (GST_stats,
3232 gettext_noop ("# Successful attempts to switch addresses"), 3214 gettext_noop ("# Successful attempts to switch addresses"),
3233 1, 3215 1,
@@ -3488,8 +3470,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3488 n->primary_address.address, 3470 n->primary_address.address,
3489 n->primary_address.session, 3471 n->primary_address.session,
3490 n->primary_address.bandwidth_in, 3472 n->primary_address.bandwidth_in,
3491 n->primary_address.bandwidth_out, 3473 n->primary_address.bandwidth_out);
3492 GNUNET_YES);
3493 return GNUNET_OK; 3474 return GNUNET_OK;
3494} 3475}
3495 3476