fix for quota check
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 14 Jan 2013 10:01:43 +0000 (10:01 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 14 Jan 2013 10:01:43 +0000 (10:01 +0000)
src/ats/gnunet-service-ats_addresses_simplistic.c

index c5e774f5623cf3304aace395db7bd30f597d8d8c..7a7c4febf335fa93ff63dc4f372c9c39430098e6 100644 (file)
@@ -502,19 +502,25 @@ update_quota_per_network (struct GAS_SIMPLISTIC_Handle *s,
 
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-                          "Total bandwidth assigned is: (in/out): %llu /%llu\n",
+                          "Total bandwidth assigned is (in/out): %llu /%llu\n",
                           quota_in_used,
                           quota_out_used);
-  if (quota_out_used > quota_out)
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-                            "DEBUG! Total inbound bandwidth assigned is larget than allowed  %llu /%llu\n",
+  if (quota_out_used > net->total_quota_out + 1) /* +1 is required due to rounding errors */
+  {
+      GNUNET_break (0);
+      LOG (GNUNET_ERROR_TYPE_WARNING,
+                            "Total inbound bandwidth assigned is larget than allowed  %llu /%llu\n",
                             quota_out_used,
-                            quota_out); /* FIXME: Can happen atm, we have some rounding error */
-  if (quota_in_used > quota_in)
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-                            "DEBUG! Total inbound bandwidth assigned is larget than allowed  %llu /%llu\n",
+                            quota_out);
+  }
+  if (quota_in_used > net->total_quota_in + 1) /* +1 is required due to rounding errors */
+  {
+      GNUNET_break (0);
+      LOG (GNUNET_ERROR_TYPE_WARNING,
+                            "Total inbound bandwidth assigned is larget than allowed  %llu /%llu\n",
                             quota_in_used,
-                            quota_in); /* FIXME: Can happen atm, we have some rounding error */
+                            quota_in);
+  }
 }
 
 static void