major bugfixes in performance api implementation, some logging
authorChristian Grothoff <christian@grothoff.org>
Wed, 19 Oct 2011 13:09:56 +0000 (13:09 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 19 Oct 2011 13:09:56 +0000 (13:09 +0000)
src/ats/gnunet-service-ats_performance.c
src/ats/gnunet-service-ats_reservations.c

index 24450031fdb74f6f8a376e0f52eeb6ab6be39ec1..19015a365a0a3f2e4315b1f7b23730632ba42a21 100644 (file)
@@ -271,7 +271,7 @@ GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
   }
   msg = (const struct ChangePreferenceMessage *) message;
   nump = ntohl (msg->num_preferences);
-  if (msize != sizeof (struct ChangePreferenceMessage) * nump * sizeof (struct PreferenceInformation))
+  if (msize != sizeof (struct ChangePreferenceMessage) + nump * sizeof (struct PreferenceInformation))
   {
     GNUNET_break (0);
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
index 96ab1cdb22185e37f76824110632ed9623d3faf6..bdc1e64c37a4392484f35bc01fa01017c44b1cfb 100644 (file)
@@ -60,16 +60,25 @@ GAS_reservations_reserve (const struct GNUNET_PeerIdentity *peer,
   tracker = GNUNET_CONTAINER_multihashmap_get (trackers,
                                               &peer->hashPubKey);
   if (NULL == tracker)
-    return GNUNET_TIME_UNIT_FOREVER_REL;
+    return GNUNET_TIME_UNIT_ZERO; /* not connected, satisfy now */
   if (amount >= 0)
   {
     ret = GNUNET_BANDWIDTH_tracker_get_delay (tracker,
                                              amount);
     if (ret.rel_value > 0)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Delay to satisfy reservation for %d bytes is %llu ms\n",
+                 (int) amount,
+                 (unsigned long long) ret.rel_value);
       return ret;
+    }
   }
   GNUNET_break (GNUNET_NO == /* no == not above limit */
                GNUNET_BANDWIDTH_tracker_consume (tracker, amount));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Reserved %d bytes\n",
+             (int) amount);
   return GNUNET_TIME_UNIT_ZERO;
 }