gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r25392 - gnunet/src/ats
Date: Tue, 11 Dec 2012 14:46:26 +0100

Author: wachs
Date: 2012-12-11 14:46:26 +0100 (Tue, 11 Dec 2012)
New Revision: 25392

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_destroy_address.c
Log:


Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2012-12-11 13:22:40 UTC 
(rev 25391)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2012-12-11 13:46:26 UTC 
(rev 25392)
@@ -324,8 +324,6 @@
                  GNUNET_CONTAINER_multihashmap_remove (handle->addresses,
                                                        &addr->peer.hashPubKey,
                                                        addr));
-
-  handle->s_del (handle->solver, handle->addresses, addr);
   free_address (addr);
   return ret;
 }

Modified: gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c    2012-12-11 
13:22:40 UTC (rev 25391)
+++ gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c    2012-12-11 
13:46:26 UTC (rev 25392)
@@ -212,10 +212,14 @@
                           struct Network *net,
                           struct ATS_Address *address_except)
 {
-  unsigned long long quota_in;
-  unsigned long long quota_out;
+  unsigned long long quota_in = 0;
+  unsigned long long quota_out = 0;
   struct AddressWrapper *cur;
 
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+              "Recalculate quota for network type `%s' for %u addresses 
(in/out): %llu/%llu \n",
+              net->desc, net->active_addresses, quota_in, quota_out);
+
   if (net->active_addresses == 0)
     return; /* no addresses to update */
 
@@ -329,15 +333,26 @@
 {
   struct GAS_SIMPLISTIC_Handle *s = solver;
   struct Network *net;
+  struct AddressWrapper *aw;
+
   /* Remove an adress completely, we have to:
    * - Remove from specific network
-   * - Decrease number of total addresses */
+   * - Decrease number of total addresses
+   * - If active:
+   *   - decrease number of active addreses
+   *   - update quotas
+   */
+
   net = (struct Network *) address->solver_information;
 
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s address %p for peer `%s' from 
network `%s' (total: %u/ active: %u)\n",
+      (GNUNET_NO == address->active) ? "inactive" : "active",
+      address, GNUNET_i2s (&address->peer),
+      net->desc, net->total_addresses, net->active_addresses);
+
   GNUNET_break (0 < net->total_addresses);
+  net->total_addresses --;
 
-
-
   if (GNUNET_YES == address->active)
   {
       /* Address was active, remove from network and update quotas*/
@@ -348,6 +363,14 @@
       update_quota_per_network (s, net, NULL);
   }
 
+  for (aw = net->head; NULL != aw; aw = aw->next)
+  {
+      if (aw->addr == address)
+        break;
+  }
+  GNUNET_CONTAINER_DLL_remove (net->head, net->tail, aw);
+  GNUNET_free (aw);
+
 }
 
 

Modified: gnunet/src/ats/test_ats_api_scheduling_destroy_address.c
===================================================================
--- gnunet/src/ats/test_ats_api_scheduling_destroy_address.c    2012-12-11 
13:22:40 UTC (rev 25391)
+++ gnunet/src/ats/test_ats_api_scheduling_destroy_address.c    2012-12-11 
13:46:26 UTC (rev 25392)
@@ -67,6 +67,18 @@
  */
 static void *test_session;
 
+/**
+ * Test ats info
+ */
+struct GNUNET_ATS_Information test_ats_info[2];
+
+/**
+ * Test ats count
+ */
+uint32_t test_ats_count;
+
+
+
 static void
 create_test_address (struct Test_Address *dest, char * plugin, void *session, 
void *addr, size_t addrlen)
 {
@@ -227,6 +239,13 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
               GNUNET_i2s_full(&p.id));
 
+  /* Prepare ATS Information */
+  test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
+  test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
+  test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
+  test_ats_info[1].value = htonl(1);
+  test_ats_count = 2;
+
   /* Adding address without session */
   test_session  = NULL;
   create_test_address (&test_addr, "test", test_session, "test", strlen 
("test") + 1);
@@ -234,7 +253,7 @@
   test_hello_address.transport_name = test_addr.plugin;
   test_hello_address.address = test_addr.addr;
   test_hello_address.address_length = test_addr.addr_len;
-  GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, NULL, 
0);
+  GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, 
test_ats_info, 2);
 
   /* Request address */
   GNUNET_ATS_suggest_address (sched_ats, &p.id);




reply via email to

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