-more datacache integration work
[oweals/gnunet.git] / src / testbed / gnunet-service-testbed_cpustatus.c
index 4b61a039c861cab6acebcec530b52a92fc926347..44d1c7624a158843e00a85d629a81a7fef0f13b1 100644 (file)
@@ -1,10 +1,10 @@
 /*
      This file is part of GNUnet.
-     (C) 2008--2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2008--2013 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -54,6 +54,9 @@
 
 static processor_cpu_load_info_t prev_cpu_load;
 #endif
+#ifdef WINDOWS
+#include <winternl.h>
+#endif
 
 #define DEBUG_STATUSCALLS GNUNET_NO
 
@@ -82,7 +85,7 @@ static double agedIOLoad = -1;
  */
 struct GNUNET_BIO_WriteHandle *bw;
 
-GNUNET_SCHEDULER_TaskIdentifier sample_load_task_id;
+struct GNUNET_SCHEDULER_Task * sample_load_task_id;
 
 
 #ifdef OSX
@@ -318,7 +321,7 @@ updateUsage ()
     kc = kstat_open ();
     if (kc == NULL)
       {
-        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kstat_close");        
+        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kstat_close");
         goto ABORT_KSTAT;
       }
 
@@ -633,7 +636,7 @@ get_nproc ()
   nproc = 0;
   while (NULL != (ent = readdir (dir)))
   {
-    if((*ent->d_name > '0') && (*ent->d_name <= '9')) 
+    if((*ent->d_name > '0') && (*ent->d_name <= '9'))
       nproc++;
   }
   closedir (dir);
@@ -653,7 +656,7 @@ sample_load_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   unsigned int mem_usage;
   unsigned int nproc;
 
-  sample_load_task_id = GNUNET_SCHEDULER_NO_TASK;
+  sample_load_task_id = NULL;
   if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
     return;
   ld_cpu = cpu_get_load ();
@@ -669,14 +672,14 @@ sample_load_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   now = GNUNET_TIME_absolute_get ();
   nbs = GNUNET_asprintf (&str, "%llu %d %d %u %u\n", now.abs_value_us / 1000LL / 1000LL,
                          ld_cpu, ld_disk, mem_usage, nproc);
-  if (0 < nbs) 
+  if (0 < nbs)
   {
     GNUNET_BIO_write (bw, str, nbs);
   }
   else
     GNUNET_break (0);
   GNUNET_free (str);
-  
+
  reschedule:
   sample_load_task_id =
       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
@@ -696,7 +699,7 @@ GST_stats_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
   char *stats_dir;
   char *fn;
   size_t len;
-  
+
 #if MINGW
   GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
               "Load statistics logging now available for windows\n");
@@ -716,7 +719,7 @@ GST_stats_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
     GNUNET_free (hostname);
     return;
   }
-  fn = NULL;  
+  fn = NULL;
   (void) GNUNET_asprintf (&fn, "%s/%.*s-%jd.dat", stats_dir, len,
                           hostname, (intmax_t) getpid());
   GNUNET_free (stats_dir);
@@ -740,7 +743,7 @@ GST_stats_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
   initMachCpuStats ();
 #endif
   updateUsage ();               /* initialize */
-  
+
 }
 
 
@@ -764,10 +767,10 @@ GST_stats_destroy ()
 #elif OSX
   GNUNET_free_non_null (prev_cpu_load);
 #endif
-  if (GNUNET_SCHEDULER_NO_TASK != sample_load_task_id)
+  if (NULL != sample_load_task_id)
   {
     GNUNET_SCHEDULER_cancel (sample_load_task_id);
-    sample_load_task_id = GNUNET_SCHEDULER_NO_TASK;
+    sample_load_task_id = NULL;
   }
   GNUNET_break (GNUNET_OK == GNUNET_BIO_write_close (bw));
   bw = NULL;