gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3543 - gnunet-gtk/src/plugins/stats


From: grothoff
Subject: [GNUnet-SVN] r3543 - gnunet-gtk/src/plugins/stats
Date: Sat, 21 Oct 2006 19:54:46 -0700 (PDT)

Author: grothoff
Date: 2006-10-21 19:54:44 -0700 (Sat, 21 Oct 2006)
New Revision: 3543

Modified:
   gnunet-gtk/src/plugins/stats/functions.c
   gnunet-gtk/src/plugins/stats/functions.h
   gnunet-gtk/src/plugins/stats/statistics.c
Log:
fixing stats

Modified: gnunet-gtk/src/plugins/stats/functions.c
===================================================================
--- gnunet-gtk/src/plugins/stats/functions.c    2006-10-22 02:48:02 UTC (rev 
3542)
+++ gnunet-gtk/src/plugins/stats/functions.c    2006-10-22 02:54:44 UTC (rev 
3543)
@@ -21,6 +21,7 @@
 
 #include "platform.h"
 #include "gnunetgtk_common.h"
+#include <GNUnet/gnunet_util_cron.h>
 #include <GNUnet/gnunet_stats_lib.h>
 #include <GNUnet/gnunet_getoption_lib.h>
 #include <GNUnet/gnunet_protocols.h>
@@ -42,6 +43,12 @@
 
 static long long bandup;
 
+static struct GE_Context * ectx;
+
+static struct GC_Configuration * cfg;
+
+static struct CronManager * cron;
+
 static int getStatValue(long long * value,
                        long long * lvalue,
                        cron_t * dtime,
@@ -410,7 +417,8 @@
   now = get_time();
   delta = now - lastUpdate;
   MUTEX_LOCK(lock);
-  if (OK == requestStatistics(sock,
+  if (OK == requestStatistics(ectx,
+                             sock,
                              &statsProcessor,
                              &delta))
     lastUpdate = now;
@@ -469,42 +477,51 @@
   },
 };
 
-static int UPDATE_INTERVAL;
+static unsigned long long UPDATE_INTERVAL;
 
-void init_functions() {
-  UPDATE_INTERVAL
-    = getConfigurationInt("GNUNET-GTK",
-                         "STATS-INTERVAL") * cronSECONDS;
-  if (UPDATE_INTERVAL == 0)
-    UPDATE_INTERVAL = 30 * cronSECONDS;
+void init_functions(struct GE_Context * e,
+                   struct GC_Configuration * c) {
+  ectx = e;
+  cfg = c;
+  GC_get_configuration_value_number(cfg,
+                                   "GNUNET-GTK",
+                                   "STATS-INTERVAL",
+                                   1,
+                                   99 * cronYEARS,
+                                   30 * cronSECONDS,
+                                   &UPDATE_INTERVAL);
   sock = client_connection_create(ectx,
                                  cfg);
   lock = MUTEX_CREATE(NO);
   updateStatValues(NULL);
   updateConnectionGoal(NULL);
-  cron_job_add(cron,
+  cron = cron_create(ectx);
+  cron_add_job(cron,
               &updateStatValues,
               UPDATE_INTERVAL,
               UPDATE_INTERVAL,
               NULL);
-  cron_job_add(cron,
+  cron_add_job(cron,
               &updateConnectionGoal,
               5 * cronMINUTES,
               5 * cronMINUTES,
               NULL);
+  cron_start(cron);
 }
 
 void done_functions() {
   int i;
 
-  cron_job_del(cron,
+  cron_stop(cron);
+  cron_del_job(cron,
               &updateConnectionGoal,
               5 * cronMINUTES,
               NULL);
-  cron_job_del(cron,
+  cron_del_job(cron,
               &updateStatValues,
               UPDATE_INTERVAL,
               NULL);
+  cron_destroy(cron);
   MUTEX_DESTROY(lock);
   connection_destroy(sock);
   for (i=0;i<lsv_size;i++)

Modified: gnunet-gtk/src/plugins/stats/functions.h
===================================================================
--- gnunet-gtk/src/plugins/stats/functions.h    2006-10-22 02:48:02 UTC (rev 
3542)
+++ gnunet-gtk/src/plugins/stats/functions.h    2006-10-22 02:54:44 UTC (rev 
3543)
@@ -50,10 +50,9 @@
 
 extern StatEntry stats[];
 
-extern int UPDATE_INTERVAL;
+void init_functions(struct GE_Context * e,
+                   struct GC_Configuration * c);
 
-void init_functions(void);
-
 void done_functions(void);
 
 #endif

Modified: gnunet-gtk/src/plugins/stats/statistics.c
===================================================================
--- gnunet-gtk/src/plugins/stats/statistics.c   2006-10-22 02:48:02 UTC (rev 
3542)
+++ gnunet-gtk/src/plugins/stats/statistics.c   2006-10-22 02:54:44 UTC (rev 
3543)
@@ -60,6 +60,8 @@
   GdkColor        mem_color[MAX_COLOR];
 } ProcConfig;
 
+static unsigned long long UPDATE_INTERVAL;
+
 /**
  * Redraws the backing pixmap for the load graph and updates the window
  */
@@ -352,7 +354,7 @@
   unsigned int i;
 
   if (stats[statIdx].count > MAX_COLOR) {
-    GE_BREAK(ectx, 0);
+    GE_BREAK(NULL, 0);
     return NULL;
   }
 
@@ -426,14 +428,23 @@
 
 
 
-void init_stats() {
+void init_stats(struct GE_Context * ectx,
+               struct GC_Configuration * cfg) {
   GtkWidget * sys_box;
   GtkWidget * label;
   GtkWidget * notebook;
   ProcConfig config;
   int i;
 
-  init_functions();
+  GC_get_configuration_value_number(cfg,
+                                   "GNUNET-GTK",
+                                   "STATS-INTERVAL",
+                                   1,
+                                   99 * cronYEARS,
+                                   30 * cronSECONDS,
+                                   &UPDATE_INTERVAL);
+  init_functions(ectx,
+                cfg);
   notebook
     = glade_xml_get_widget(getMainXML(),
                           "statsNotebook");





reply via email to

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