gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35197 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r35197 - gnunet/src/ats
Date: Mon, 9 Feb 2015 16:30:22 +0100

Author: grothoff
Date: 2015-02-09 16:30:22 +0100 (Mon, 09 Feb 2015)
New Revision: 35197

Modified:
   gnunet/src/ats/gnunet-service-ats_plugins.c
   gnunet/src/ats/gnunet-service-ats_scheduling.c
Log:
do proper check for stability, in particular UINT32_MAX-0 is not a delta of 1...

Modified: gnunet/src/ats/gnunet-service-ats_plugins.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_plugins.c 2015-02-09 15:12:40 UTC (rev 
35196)
+++ gnunet/src/ats/gnunet-service-ats_plugins.c 2015-02-09 15:30:22 UTC (rev 
35197)
@@ -190,6 +190,7 @@
                (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
     return;
   default:
+    GNUNET_break (0);
     break;
   }
 }
@@ -205,12 +206,14 @@
 bandwidth_changed_cb (void *cls,
                      struct ATS_Address *address)
 {
-  uint32_t diff_out;
-  uint32_t diff_in;
+  long long diff_out;
+  long long diff_in;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Bandwidth assignment changed for peer %s \n",
-              GNUNET_i2s (&address->peer));
+              "Bandwidth assignment changed for peer %s to %u/%u\n",
+              GNUNET_i2s (&address->peer),
+              (unsigned int) address->assigned_bw_in,
+              (unsigned int) address->assigned_bw_out);
 
   /* Notify performance clients about changes to address */
   GAS_performance_notify_all_clients (&address->peer,
@@ -226,7 +229,7 @@
   if ( (0 == address->assigned_bw_in) &&
        (0 == address->assigned_bw_out) )
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Telling transport to disconnect peer `%s'\n",
                 GNUNET_i2s (&address->peer));
 
@@ -239,14 +242,19 @@
   }
 
   /* Do bandwidth stability check */
-  diff_out = abs (address->assigned_bw_out - address->last_notified_bw_out);
-  diff_in = abs (address->assigned_bw_in - address->last_notified_bw_in);
-
-  if ( (diff_out < htonl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) &&
-       (diff_in < htonl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) )
+  diff_out = llabs ((long long) address->assigned_bw_out -
+                    (long long) address->last_notified_bw_out);
+  diff_in = llabs ((long long) address->assigned_bw_in -
+                   (long long) address->last_notified_bw_in);
+  if ( (diff_out < htonl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) &&
+       (diff_in < htonl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) )
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Bandwidth change too small, not notifying client\n");
     return;
+  }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Sending bandwidth update for peer `%s': %u/%u\n",
               GNUNET_i2s (&address->peer),
               address->assigned_bw_out,

Modified: gnunet/src/ats/gnunet-service-ats_scheduling.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_scheduling.c      2015-02-09 15:12:40 UTC 
(rev 35196)
+++ gnunet/src/ats/gnunet-service-ats_scheduling.c      2015-02-09 15:30:22 UTC 
(rev 35197)
@@ -206,9 +206,6 @@
   uint32_t ats_count;
   uint16_t size;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received `%s' message\n",
-              "ADDRESS_UPDATE");
   size = ntohs (message->size);
   if (size < sizeof (struct AddressUpdateMessage))
   {




reply via email to

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