gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r38173 - in gnunet/src: curl statistics


From: gnunet
Subject: [GNUnet-SVN] r38173 - in gnunet/src: curl statistics
Date: Fri, 21 Oct 2016 16:26:16 +0200

Author: grothoff
Date: 2016-10-21 16:26:15 +0200 (Fri, 21 Oct 2016)
New Revision: 38173

Modified:
   gnunet/src/curl/curl.c
   gnunet/src/statistics/statistics_api.c
   gnunet/src/statistics/test_statistics_api.c
   gnunet/src/statistics/test_statistics_api_loop.c
Log:
improve test shutdown and indentation

Modified: gnunet/src/curl/curl.c
===================================================================
--- gnunet/src/curl/curl.c      2016-10-21 05:33:35 UTC (rev 38172)
+++ gnunet/src/curl/curl.c      2016-10-21 14:26:15 UTC (rev 38173)
@@ -407,7 +407,6 @@
     }
     return NULL;
   }
-
   json = NULL;
   if (0 == db->eno)
   {

Modified: gnunet/src/statistics/statistics_api.c
===================================================================
--- gnunet/src/statistics/statistics_api.c      2016-10-21 05:33:35 UTC (rev 
38172)
+++ gnunet/src/statistics/statistics_api.c      2016-10-21 14:26:15 UTC (rev 
38173)
@@ -1015,7 +1015,7 @@
     return;
   }
   if (0 < GNUNET_MQ_get_length (h->mq))
-    return; /* Wait for queue to be reduced more */
+    return; /* Wait for queue to be reduced more */    
   /* schedule next action */
   while (NULL == h->current)
   {
@@ -1253,8 +1253,10 @@
   }
   for (ai = h->action_head; NULL != ai; ai = ai->next)
   {
-    if (! ( (0 == strcmp (ai->subsystem, h->subsystem)) &&
-           (0 == strcmp (ai->name, name)) &&
+    if (! ( (0 == strcmp (ai->subsystem,
+                         h->subsystem)) &&
+           (0 == strcmp (ai->name,
+                         name)) &&
            ( (ACTION_UPDATE == ai->type) ||
              (ACTION_SET == ai->type) ) ) )
       continue;

Modified: gnunet/src/statistics/test_statistics_api.c
===================================================================
--- gnunet/src/statistics/test_statistics_api.c 2016-10-21 05:33:35 UTC (rev 
38172)
+++ gnunet/src/statistics/test_statistics_api.c 2016-10-21 14:26:15 UTC (rev 
38173)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009, 2012 GNUnet e.V.
+     Copyright (C) 2009, 2012, 2016 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -29,7 +29,22 @@
 
 static struct GNUNET_STATISTICS_Handle *h;
 
+static struct GNUNET_STATISTICS_GetHandle *g;
 
+
+static void
+do_shutdown ()
+{
+  if (NULL != g)
+  {
+    GNUNET_STATISTICS_get_cancel (g);
+    g = NULL;
+  }
+  GNUNET_STATISTICS_destroy (h, GNUNET_NO);
+  h = NULL;
+}
+
+
 static int
 check_1 (void *cls,
          const char *subsystem,
@@ -96,7 +111,8 @@
 {
   int *ok = cls;
 
-  GNUNET_STATISTICS_destroy (h, GNUNET_NO);
+  g = NULL;
+  GNUNET_SCHEDULER_shutdown ();
   GNUNET_assert (success == GNUNET_OK);
   *ok = 0;
 }
@@ -105,6 +121,7 @@
 static void
 next (void *cls, int success)
 {
+  g = NULL;
   GNUNET_assert (success == GNUNET_OK);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Issuing GET request\n");
@@ -122,15 +139,23 @@
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   h = GNUNET_STATISTICS_create ("test-statistics-api", cfg);
+  if (NULL == h)
+  {
+    GNUNET_break (0);
+    return;
+  }
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+                                NULL);
   GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO);
   GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO);
   GNUNET_STATISTICS_set (h, "test-3", 2, GNUNET_NO);
   GNUNET_STATISTICS_update (h, "test-3", 1, GNUNET_YES);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Issuing GET request\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Issuing GET request\n");
   GNUNET_break (NULL !=
-                GNUNET_STATISTICS_get (h, NULL, "test-1",
-                                       &next,
-                                       &check_1, cls));
+                (g = GNUNET_STATISTICS_get (h, NULL, "test-1",
+                                           &next,
+                                           &check_1, cls)));
 }
 
 
@@ -142,11 +167,13 @@
 {
   h = GNUNET_STATISTICS_create ("test-statistics-api",
                                 cfg);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+                                NULL);
   GNUNET_break (NULL !=
-                GNUNET_STATISTICS_get (h, NULL,
-                                       "test-3",
-                                       &next_fin,
-                                       &check_3, cls));
+                (g = GNUNET_STATISTICS_get (h, NULL,
+                                           "test-3",
+                                           &next_fin,
+                                           &check_3, cls)));
 }
 
 

Modified: gnunet/src/statistics/test_statistics_api_loop.c
===================================================================
--- gnunet/src/statistics/test_statistics_api_loop.c    2016-10-21 05:33:35 UTC 
(rev 38172)
+++ gnunet/src/statistics/test_statistics_api_loop.c    2016-10-21 14:26:15 UTC 
(rev 38173)
@@ -31,7 +31,10 @@
 
 
 static int
-check_1 (void *cls, const char *subsystem, const char *name, uint64_t value,
+check_1 (void *cls,
+        const char *subsystem,
+        const char *name,
+        uint64_t value,
          int is_persistent)
 {
   GNUNET_assert (0 == strcmp (name, "test-0"));
@@ -42,7 +45,8 @@
 
 
 static void
-next (void *cls, int success)
+next (void *cls,
+      int success)
 {
   int *ok = cls;
 
@@ -53,7 +57,9 @@
 
 
 static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+     char *const *args,
+     const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   unsigned int i;
@@ -62,9 +68,9 @@
   h = GNUNET_STATISTICS_create ("test-statistics-api-loop", cfg);
   for (i = 0; i < ROUNDS; i++)
   {
-    GNUNET_snprintf (name, sizeof (name), "test-%d", i % 256);
+    GNUNET_snprintf (name, sizeof (name), "test-%d", i % 32);
     GNUNET_STATISTICS_set (h, name, i, GNUNET_NO);
-    GNUNET_snprintf (name, sizeof (name), "test-%d", i % 128);
+    GNUNET_snprintf (name, sizeof (name), "test-%d", i % 16);
     GNUNET_STATISTICS_update (h, name, 1, GNUNET_NO);
   }
   i = 0;




reply via email to

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