gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r21174 - gnunet/src/statistics


From: gnunet
Subject: [GNUnet-SVN] r21174 - gnunet/src/statistics
Date: Thu, 26 Apr 2012 17:15:03 +0200

Author: wachs
Date: 2012-04-26 17:15:03 +0200 (Thu, 26 Apr 2012)
New Revision: 21174

Modified:
   gnunet/src/statistics/gnunet-statistics.c
Log:
- continous watch for statistics


Modified: gnunet/src/statistics/gnunet-statistics.c
===================================================================
--- gnunet/src/statistics/gnunet-statistics.c   2012-04-26 13:55:42 UTC (rev 
21173)
+++ gnunet/src/statistics/gnunet-statistics.c   2012-04-26 15:15:03 UTC (rev 
21174)
@@ -53,6 +53,11 @@
 static int persistent;
 
 /**
+ * Watch value continuously
+ */
+static int watch;
+
+/**
  * Quiet mode
  */
 static int quiet;
@@ -101,8 +106,15 @@
   if (h != NULL)
     GNUNET_STATISTICS_destroy (h, GNUNET_NO);
 }
+static void
+shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNUNET_STATISTICS_Handle *h = cls;
+  GNUNET_STATISTICS_watch_cancel (h, subsystem, name, &printer, h);
+  if (h != NULL)
+    GNUNET_STATISTICS_destroy (h, GNUNET_NO);
+}
 
-
 /**
  * Main function that will be run by the scheduler.
  *
@@ -143,10 +155,26 @@
     ret = 1;
     return;
   }
-  if (NULL ==
+  if (GNUNET_NO == watch)
+  {
+    if (NULL ==
       GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, &cleanup,
                              &printer, h))
     cleanup (h, GNUNET_SYSERR);
+  }
+  else
+  {
+    if ((NULL == subsystem) || (NULL == name))
+    {
+      printf (_("No subsystem or name given\n"));
+      if (h != NULL)
+        GNUNET_STATISTICS_destroy (h, GNUNET_NO);
+      ret = 1;
+      return;
+    }
+    GNUNET_STATISTICS_watch(h, subsystem, name, &printer, h);
+    GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 
h);
+  }
 }
 
 /**
@@ -172,6 +200,9 @@
     {'q', "quiet", NULL,
      gettext_noop ("just print the statistics value"), 0,
      &GNUNET_GETOPT_set_one, &quiet},
+    {'w', "watch", NULL,
+     gettext_noop ("watch value continously"), 0,
+     &GNUNET_GETOPT_set_one, &watch},
     GNUNET_GETOPT_OPTION_END
   };
   return (GNUNET_OK ==




reply via email to

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