gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r25382 - gnunet/src/ats
Date: Tue, 11 Dec 2012 11:08:48 +0100

Author: wachs
Date: 2012-12-11 11:08:48 +0100 (Tue, 11 Dec 2012)
New Revision: 25382

Modified:
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c
   gnunet/src/ats/test_ats_api_scheduling_add_address.c
Log:
changes


Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2012-12-11 09:30:58 UTC 
(rev 25381)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2012-12-11 10:08:48 UTC 
(rev 25382)
@@ -972,6 +972,7 @@
                                               ats, ats_count,
                                               address->assigned_bw_out,
                                               address->assigned_bw_in);
+  GNUNET_free (ats);
 }
 
 

Modified: gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c    2012-12-11 
09:30:58 UTC (rev 25381)
+++ gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c    2012-12-11 
10:08:48 UTC (rev 25382)
@@ -152,6 +152,7 @@
   for (c = 0; c < dest_length; c++)
   {
       cur = &s->network_entries[c];
+      cur->active_addresses = 0;
       cur->type = network[c];
       cur->total_quota_in = in_quota[c];
       cur->total_quota_out = out_quota[c];
@@ -193,7 +194,7 @@
 }
 
 static void
-update_quota (struct GAS_SIMPLISTIC_Handle *s, struct Network *net)
+update_quota_per_network (struct GAS_SIMPLISTIC_Handle *s, struct Network *net)
 {
   unsigned long long quota_in;
   unsigned long long quota_out;
@@ -203,8 +204,8 @@
   quota_out = net->total_quota_out / net->active_addresses;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-              "New quota for network type `%s' (in/out): %llu/%llu \n",
-              net->desc, quota_in, quota_out);
+              "New per address quota for network type `%s' for %u addresses 
(in/out): %llu/%llu \n",
+              net->desc, net->active_addresses, quota_in, quota_out);
 
   cur = net->head;
   while (NULL != cur)
@@ -216,7 +217,8 @@
         cur->addr->assigned_bw_in.value__ = htonl (quota_in);
         cur->addr->assigned_bw_out.value__ = htonl (quota_out);
         /* Notify on change */
-        s->bw_changed (cur->addr);
+        if (GNUNET_YES == cur->addr->active)
+          s->bw_changed (cur->addr);
       }
       cur = cur->next;
   }
@@ -262,7 +264,7 @@
               cur->active_addresses);
 
   /* Update quota for this network type */
-  update_quota (s, cur);
+  update_quota_per_network (s, cur);
 }
 
 
@@ -294,7 +296,7 @@
   }
 
   /* Update quota for this network type */
-  update_quota (s, c);
+  update_quota_per_network (s, c);
 #endif
 }
 
@@ -328,7 +330,7 @@
   }
 
   /* Update quota for this network type */
-  update_quota (s, c);
+  update_quota_per_network (s, c);
 #endif
 }
 
@@ -435,26 +437,28 @@
                                const struct GNUNET_PeerIdentity *peer)
 {
   struct GAS_SIMPLISTIC_Handle *s = solver;
-  struct ATS_Address *aa;
-  struct ATS_Address *previous;
+  struct Network *net_prev;
+  struct Network *net_cur;
+  struct ATS_Address *cur;
+  struct ATS_Address *prev;
 
   GNUNET_assert (s != NULL);
-  aa = NULL;
+  cur = NULL;
   /* Get address with: stick to current address, lower distance, lower latency 
*/
   GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
-                                              &find_address_it, &aa);
-  if (NULL == aa)
+                                              &find_address_it, &cur);
+  if (NULL == cur)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Cannot suggest address for peer `%s'\n", 
GNUNET_i2s (peer));
     return NULL;
   }
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Suggesting address %p for peer `%s'\n", aa, 
GNUNET_i2s (peer));
-
-  if (GNUNET_YES == aa->active)
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Suggesting address %p for peer `%s'\n", cur, 
GNUNET_i2s (peer));
+  net_cur = (struct Network *) cur->solver_information;
+  if (GNUNET_YES == cur->active)
   {
       /* This address was selected previously, so no need to update quotas */
-      return aa;
+      return cur;
   }
 
   /* This address was not active, so we have to:
@@ -464,17 +468,23 @@
    * - update quota for this address network
    */
 
-  previous = find_active_address (solver, addresses, peer);
-  if (NULL == previous)
+  prev = find_active_address (s, addresses, peer);
+  if (NULL != prev)
   {
-     /* No currently address, nothing to do */
-     return aa;
+      net_prev = (struct Network *) prev->solver_information;
+      prev->active = GNUNET_NO; /* No active any longer */
+      prev->assigned_bw_in = GNUNET_BANDWIDTH_value_init (0); /* no bw 
assigned */
+      prev->assigned_bw_out = GNUNET_BANDWIDTH_value_init (0); /* no bw 
assigned */
+      s->bw_changed (prev); /* notify about bw change, REQUIERED? */
+      net_cur->active_addresses --;
+      update_quota_per_network (s, net_prev);
   }
 
-  aa->active = GNUNET_YES;
-  s->active_addresses++;
+  cur->active = GNUNET_YES;
+  net_cur->active_addresses ++;
+  update_quota_per_network (s, net_cur);
 
-  return aa;
+  return cur;
 }
 
 

Modified: gnunet/src/ats/test_ats_api_scheduling_add_address.c
===================================================================
--- gnunet/src/ats/test_ats_api_scheduling_add_address.c        2012-12-11 
09:30:58 UTC (rev 25381)
+++ gnunet/src/ats/test_ats_api_scheduling_add_address.c        2012-12-11 
10:08:48 UTC (rev 25382)
@@ -111,7 +111,8 @@
     GNUNET_SCHEDULER_cancel (die_task);
     die_task = GNUNET_SCHEDULER_NO_TASK;
   }
-  GNUNET_ATS_scheduling_done (sched_ats);
+  if (NULL != sched_ats)
+    GNUNET_ATS_scheduling_done (sched_ats);
   sched_ats = NULL;
   free_test_address (&test_addr);
 }
@@ -204,27 +205,31 @@
                     const struct GNUNET_ATS_Information *atsi,
                     uint32_t ats_count)
 {
-  if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, 
test_session))
+  static int stage = 0;
+  if (0 == stage)
   {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct 
address `%s'\n",
-                  GNUNET_i2s (&address->peer));
-      ret = 0;
-  }
-  else
-  {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid 
address `%s'\n",
-                  GNUNET_i2s (&address->peer));
+    if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, 
test_session))
+    {
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct 
address `%s'\n",
+                    GNUNET_i2s (&address->peer));
+        ret = 0;
+    }
+    else
+    {
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid 
address `%s'\n",
+                    GNUNET_i2s (&address->peer));
+        ret = 1;
+    }
+
+    if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, 
test_ats_count))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect 
ats info \n");
       ret = 1;
+    }
+    stage ++;
+    GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
+    GNUNET_SCHEDULER_add_now (&end, NULL);
   }
-
-  if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect ats 
info \n");
-    ret = 1;
-  }
-
-  GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
-  GNUNET_SCHEDULER_add_now (&end, NULL);
 }
 
 static void




reply via email to

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