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)
{
}
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;
/*
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
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,
{
int *ok = cls;
- GNUNET_STATISTICS_destroy (h, GNUNET_NO);
+ g = NULL;
+ GNUNET_SCHEDULER_shutdown ();
GNUNET_assert (success == GNUNET_OK);
*ok = 0;
}
static void
next (void *cls, int success)
{
+ g = NULL;
GNUNET_assert (success == GNUNET_OK);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Issuing GET request\n");
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)));
}
{
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)));
}
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"));
static void
-next (void *cls, int success)
+next (void *cls,
+ int success)
{
int *ok = cls;
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;
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;