diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-07 20:41:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-07 20:41:48 +0000 |
commit | 77ea8dbe440a1a9780644876430292f65f5de51c (patch) | |
tree | 5c87fce4408cf534990fccdc9bcb19763ed5750c | |
parent | 9ee55ce36b1b2da9d3d2bb82bea555294b35637d (diff) | |
download | gnunet-77ea8dbe440a1a9780644876430292f65f5de51c.tar.gz gnunet-77ea8dbe440a1a9780644876430292f65f5de51c.zip |
act on received SessionQuotaMessages
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 403eba3f6..87dd9c213 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -411,9 +411,8 @@ struct NeighbourMapEntry | |||
411 | * Latest quota the other peer send us in bytes per second. | 411 | * Latest quota the other peer send us in bytes per second. |
412 | * We should not send more, least the other peer throttle | 412 | * We should not send more, least the other peer throttle |
413 | * receiving our traffic. | 413 | * receiving our traffic. |
414 | * FIXME: Not used (#3652). | ||
415 | */ | 414 | */ |
416 | unsigned int neighbour_receive_quota; | 415 | struct GNUNET_BANDWIDTH_Value32NBO neighbour_receive_quota; |
417 | 416 | ||
418 | /** | 417 | /** |
419 | * The current state of the peer. | 418 | * The current state of the peer. |
@@ -669,13 +668,15 @@ test_connected (struct NeighbourMapEntry *n) | |||
669 | 668 | ||
670 | /** | 669 | /** |
671 | * Send information about a new outbound quota to our clients. | 670 | * Send information about a new outbound quota to our clients. |
671 | * Note that the outbound quota is enforced client-side (i.e. | ||
672 | * in libgnunettransport). | ||
672 | * | 673 | * |
673 | * @param target affected peer | 674 | * @param target affected peer |
674 | * @param quota new quota | 675 | * @param quota new quota |
675 | */ | 676 | */ |
676 | static void | 677 | static void |
677 | send_outbound_quota (const struct GNUNET_PeerIdentity *target, | 678 | send_outbound_quota_to_clients (const struct GNUNET_PeerIdentity *target, |
678 | struct GNUNET_BANDWIDTH_Value32NBO quota) | 679 | struct GNUNET_BANDWIDTH_Value32NBO quota) |
679 | { | 680 | { |
680 | struct QuotaSetMessage q_msg; | 681 | struct QuotaSetMessage q_msg; |
681 | 682 | ||
@@ -891,8 +892,8 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
891 | if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__) | 892 | if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__) |
892 | { | 893 | { |
893 | n->primary_address.bandwidth_out = bandwidth_out; | 894 | n->primary_address.bandwidth_out = bandwidth_out; |
894 | send_outbound_quota (&address->peer, | 895 | send_outbound_quota_to_clients (&address->peer, |
895 | bandwidth_out); | 896 | bandwidth_out); |
896 | } | 897 | } |
897 | return; | 898 | return; |
898 | } | 899 | } |
@@ -929,8 +930,8 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
929 | GNUNET_YES); | 930 | GNUNET_YES); |
930 | GST_neighbours_set_incoming_quota (&address->peer, | 931 | GST_neighbours_set_incoming_quota (&address->peer, |
931 | bandwidth_in); | 932 | bandwidth_in); |
932 | send_outbound_quota (&address->peer, | 933 | send_outbound_quota_to_clients (&address->peer, |
933 | bandwidth_out); | 934 | bandwidth_out); |
934 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 935 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
935 | "Neighbour `%s' switched to address `%s'\n", | 936 | "Neighbour `%s' switched to address `%s'\n", |
936 | GNUNET_i2s (&n->id), | 937 | GNUNET_i2s (&n->id), |
@@ -2479,6 +2480,7 @@ try_run_fast_ats_update (const struct GNUNET_HELLO_Address *address, | |||
2479 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 2480 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
2480 | { | 2481 | { |
2481 | struct NeighbourMapEntry *n; | 2482 | struct NeighbourMapEntry *n; |
2483 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_min; | ||
2482 | 2484 | ||
2483 | n = lookup_neighbour (&address->peer); | 2485 | n = lookup_neighbour (&address->peer); |
2484 | if ( (NULL == n) || | 2486 | if ( (NULL == n) || |
@@ -2501,8 +2503,10 @@ try_run_fast_ats_update (const struct GNUNET_HELLO_Address *address, | |||
2501 | n->primary_address.bandwidth_out = bandwidth_out; | 2503 | n->primary_address.bandwidth_out = bandwidth_out; |
2502 | GST_neighbours_set_incoming_quota (&address->peer, | 2504 | GST_neighbours_set_incoming_quota (&address->peer, |
2503 | bandwidth_in); | 2505 | bandwidth_in); |
2504 | send_outbound_quota (&address->peer, | 2506 | bandwidth_min = GNUNET_BANDWIDTH_value_min (bandwidth_out, |
2505 | bandwidth_out); | 2507 | n->neighbour_receive_quota); |
2508 | send_outbound_quota_to_clients (&address->peer, | ||
2509 | bandwidth_min); | ||
2506 | return GNUNET_OK; | 2510 | return GNUNET_OK; |
2507 | } | 2511 | } |
2508 | 2512 | ||
@@ -3633,6 +3637,7 @@ GST_neighbours_handle_quota_message (const struct GNUNET_PeerIdentity *peer, | |||
3633 | { | 3637 | { |
3634 | struct NeighbourMapEntry *n; | 3638 | struct NeighbourMapEntry *n; |
3635 | const struct SessionQuotaMessage *sqm; | 3639 | const struct SessionQuotaMessage *sqm; |
3640 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_min; | ||
3636 | 3641 | ||
3637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3642 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3638 | "Received QUOTA message from peer `%s'\n", | 3643 | "Received QUOTA message from peer `%s'\n", |
@@ -3656,8 +3661,12 @@ GST_neighbours_handle_quota_message (const struct GNUNET_PeerIdentity *peer, | |||
3656 | /* gone already */ | 3661 | /* gone already */ |
3657 | return; | 3662 | return; |
3658 | } | 3663 | } |
3659 | n->neighbour_receive_quota = ntohl (sqm->quota); | 3664 | n->neighbour_receive_quota = GNUNET_BANDWIDTH_value_init (ntohl (sqm->quota)); |
3660 | /* FIXME: tell someone? (#3652) */ | 3665 | |
3666 | bandwidth_min = GNUNET_BANDWIDTH_value_min (n->primary_address.bandwidth_out, | ||
3667 | n->neighbour_receive_quota); | ||
3668 | send_outbound_quota_to_clients (peer, | ||
3669 | bandwidth_min); | ||
3661 | } | 3670 | } |
3662 | 3671 | ||
3663 | 3672 | ||