gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r25459 - gnunet/src/ats
Date: Thu, 13 Dec 2012 17:13:11 +0100

Author: wachs
Date: 2012-12-13 17:13:11 +0100 (Thu, 13 Dec 2012)
New Revision: 25459

Modified:
   gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c
Log:
statistics for solver


Modified: gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c    2012-12-13 
15:45:18 UTC (rev 25458)
+++ gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c    2012-12-13 
16:13:11 UTC (rev 25459)
@@ -61,13 +61,40 @@
  */
 struct GAS_SIMPLISTIC_Handle
 {
+  /**
+   * Statistics handle
+   */
+
+  struct GNUNET_STATISTICS_Handle *stats;
+
+  /**
+   * Total number of addresses for solver
+   */
   unsigned int total_addresses;
+
+  /**
+   * Number of active addresses for solver
+   */
   unsigned int active_addresses;
 
+  /**
+   * Networks array
+   */
   struct Network *network_entries;
 
+  /**
+   * Number of networks
+   */
   unsigned int networks;
+
+  /**
+   * Callback
+   */
   GAS_bandwidth_changed_cb bw_changed;
+
+  /**
+   * Callback cls
+   */
   void *bw_changed_cls;
 };
 
@@ -105,6 +132,16 @@
    */
   unsigned int total_addresses;
 
+  /**
+   * String for statistics total addresses
+   */
+  char *stat_total;
+
+  /**
+   * String for statistics active addresses
+   */
+  char *stat_active;
+
   struct AddressWrapper *head;
   struct AddressWrapper *tail;
 };
@@ -156,6 +193,8 @@
   struct Network * cur;
   char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
 
+
+  s->stats = (struct GNUNET_STATISTICS_Handle *) stats;
   s->bw_changed = bw_changed_cb;
   s->bw_changed_cls = bw_changed_cb_cls;
   s->networks = dest_length;
@@ -172,6 +211,8 @@
       cur->total_quota_in = in_quota[c];
       cur->total_quota_out = out_quota[c];
       cur->desc = net_str[c];
+      GNUNET_asprintf (&cur->stat_total, "# ATS addresses %s total", 
cur->desc);
+      GNUNET_asprintf (&cur->stat_active, "# ATS active addresses %s total", 
cur->desc);
   }
   return s;
 }
@@ -219,8 +260,9 @@
                                        s->network_entries[c].tail,
                                        cur);
           GNUNET_free (cur);
-
       }
+      GNUNET_free (s->network_entries[c].stat_total);
+      GNUNET_free (s->network_entries[c].stat_active);
   }
   if (s->total_addresses > 0)
   {
@@ -298,13 +340,17 @@
 {
   if (GNUNET_YES == total)
   {
-  s->total_addresses ++;
-  net->total_addresses ++;
+      s->total_addresses ++;
+      net->total_addresses ++;
+      GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", 1, 
GNUNET_NO);
+      GNUNET_STATISTICS_update (s->stats, net->stat_total, 1, GNUNET_NO);
   }
   if (GNUNET_YES == active)
   {
     net->active_addresses ++;
     s->active_addresses ++;
+    GNUNET_STATISTICS_update (s->stats, "# ATS active addresses total", 1, 
GNUNET_NO);
+    GNUNET_STATISTICS_update (s->stats, net->stat_active, 1, GNUNET_NO);
   }
 
 }
@@ -324,14 +370,20 @@
       res = GNUNET_SYSERR;
     }
     else
+    {
       s->total_addresses --;
+      GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", -1, 
GNUNET_NO);
+    }
     if (net->total_addresses < 1)
     {
       GNUNET_break (0);
       res = GNUNET_SYSERR;
     }
     else
+    {
       net->total_addresses --;
+      GNUNET_STATISTICS_update (s->stats, net->stat_total, -1, GNUNET_NO);
+    }
   }
 
   if (GNUNET_YES == active)
@@ -342,14 +394,20 @@
       res = GNUNET_SYSERR;
     }
     else
+    {
       net->active_addresses --;
+      GNUNET_STATISTICS_update (s->stats, net->stat_active, -1, GNUNET_NO);
+    }
     if (s->active_addresses < 1)
     {
       GNUNET_break (0);
       res = GNUNET_SYSERR;
     }
     else
+    {
       s->active_addresses --;
+      GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", -1, 
GNUNET_NO);
+    }
   }
   return res;
 }




reply via email to

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