gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35357 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r35357 - gnunet/src/transport
Date: Sat, 7 Mar 2015 21:41:48 +0100

Author: grothoff
Date: 2015-03-07 21:41:48 +0100 (Sat, 07 Mar 2015)
New Revision: 35357

Modified:
   gnunet/src/transport/gnunet-service-transport_neighbours.c
Log:
act on received SessionQuotaMessages

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-03-07 
20:18:54 UTC (rev 35356)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-03-07 
20:41:48 UTC (rev 35357)
@@ -411,9 +411,8 @@
    * Latest quota the other peer send us in bytes per second.
    * We should not send more, least the other peer throttle
    * receiving our traffic.
-   * FIXME: Not used (#3652).
    */
-  unsigned int neighbour_receive_quota;
+  struct GNUNET_BANDWIDTH_Value32NBO neighbour_receive_quota;
 
   /**
    * The current state of the peer.
@@ -669,13 +668,15 @@
 
 /**
  * Send information about a new outbound quota to our clients.
+ * Note that the outbound quota is enforced client-side (i.e.
+ * in libgnunettransport).
  *
  * @param target affected peer
  * @param quota new quota
  */
 static void
-send_outbound_quota (const struct GNUNET_PeerIdentity *target,
-                     struct GNUNET_BANDWIDTH_Value32NBO quota)
+send_outbound_quota_to_clients (const struct GNUNET_PeerIdentity *target,
+                                struct GNUNET_BANDWIDTH_Value32NBO quota)
 {
   struct QuotaSetMessage q_msg;
 
@@ -891,8 +892,8 @@
     if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__)
     {
       n->primary_address.bandwidth_out = bandwidth_out;
-      send_outbound_quota (&address->peer,
-                           bandwidth_out);
+      send_outbound_quota_to_clients (&address->peer,
+                                      bandwidth_out);
     }
     return;
   }
@@ -929,8 +930,8 @@
                                   GNUNET_YES);
   GST_neighbours_set_incoming_quota (&address->peer,
                                      bandwidth_in);
-  send_outbound_quota (&address->peer,
-                       bandwidth_out);
+  send_outbound_quota_to_clients (&address->peer,
+                                  bandwidth_out);
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Neighbour `%s' switched to address `%s'\n",
               GNUNET_i2s (&n->id),
@@ -2479,6 +2480,7 @@
                          struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
 {
   struct NeighbourMapEntry *n;
+  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_min;
 
   n = lookup_neighbour (&address->peer);
   if ( (NULL == n) ||
@@ -2501,8 +2503,10 @@
   n->primary_address.bandwidth_out = bandwidth_out;
   GST_neighbours_set_incoming_quota (&address->peer,
                                      bandwidth_in);
-  send_outbound_quota (&address->peer,
-                       bandwidth_out);
+  bandwidth_min = GNUNET_BANDWIDTH_value_min (bandwidth_out,
+                                              n->neighbour_receive_quota);
+  send_outbound_quota_to_clients (&address->peer,
+                                  bandwidth_min);
   return GNUNET_OK;
 }
 
@@ -3633,6 +3637,7 @@
 {
   struct NeighbourMapEntry *n;
   const struct SessionQuotaMessage *sqm;
+  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_min;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received QUOTA message from peer `%s'\n",
@@ -3656,8 +3661,12 @@
     /* gone already */
     return;
   }
-  n->neighbour_receive_quota = ntohl (sqm->quota);
-  /* FIXME: tell someone? (#3652) */
+  n->neighbour_receive_quota = GNUNET_BANDWIDTH_value_init (ntohl 
(sqm->quota));
+
+  bandwidth_min = GNUNET_BANDWIDTH_value_min (n->primary_address.bandwidth_out,
+                                              n->neighbour_receive_quota);
+  send_outbound_quota_to_clients (peer,
+                                  bandwidth_min);
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]