aboutsummaryrefslogtreecommitdiff
path: root/src/statistics
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/statistics
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/statistics')
-rw-r--r--src/statistics/gnunet-service-statistics.c92
-rw-r--r--src/statistics/gnunet-statistics.c30
-rw-r--r--src/statistics/statistics_api.c109
-rw-r--r--src/statistics/test_statistics_api.c60
-rw-r--r--src/statistics/test_statistics_api_loop.c23
-rw-r--r--src/statistics/test_statistics_api_watch.c39
6 files changed, 156 insertions, 197 deletions
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c
index 5e0be1183..3305dc6f4 100644
--- a/src/statistics/gnunet-service-statistics.c
+++ b/src/statistics/gnunet-service-statistics.c
@@ -181,8 +181,8 @@ load (struct GNUNET_SERVER_Handle *server)
181 char *buf; 181 char *buf;
182 struct GNUNET_SERVER_MessageStreamTokenizer *mst; 182 struct GNUNET_SERVER_MessageStreamTokenizer *mst;
183 183
184 fn = GNUNET_DISK_get_home_filename (cfg, 184 fn = GNUNET_DISK_get_home_filename (cfg, "statistics", "statistics.data",
185 "statistics", "statistics.data", NULL); 185 NULL);
186 if (fn == NULL) 186 if (fn == NULL)
187 return; 187 return;
188 if ((0 != stat (fn, &sb)) || (sb.st_size == 0)) 188 if ((0 != stat (fn, &sb)) || (sb.st_size == 0))
@@ -209,10 +209,8 @@ load (struct GNUNET_SERVER_Handle *server)
209 (unsigned long long) sb.st_size, fn); 209 (unsigned long long) sb.st_size, fn);
210 mst = GNUNET_SERVER_mst_create (&inject_message, server); 210 mst = GNUNET_SERVER_mst_create (&inject_message, server);
211 GNUNET_break (GNUNET_OK == 211 GNUNET_break (GNUNET_OK ==
212 GNUNET_SERVER_mst_receive (mst, 212 GNUNET_SERVER_mst_receive (mst, NULL, buf, sb.st_size,
213 NULL, 213 GNUNET_YES, GNUNET_NO));
214 buf,
215 sb.st_size, GNUNET_YES, GNUNET_NO));
216 GNUNET_SERVER_mst_destroy (mst); 214 GNUNET_SERVER_mst_destroy (mst);
217 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_unmap (mh)); 215 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_unmap (mh));
218 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh)); 216 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh));
@@ -232,12 +230,12 @@ save ()
232 unsigned long long total; 230 unsigned long long total;
233 231
234 fh = NULL; 232 fh = NULL;
235 fn = GNUNET_DISK_get_home_filename (cfg, 233 fn = GNUNET_DISK_get_home_filename (cfg, "statistics", "statistics.data",
236 "statistics", "statistics.data", NULL); 234 NULL);
237 if (fn != NULL) 235 if (fn != NULL)
238 fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_WRITE 236 fh = GNUNET_DISK_file_open (fn,
239 | GNUNET_DISK_OPEN_CREATE | 237 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE
240 GNUNET_DISK_OPEN_TRUNCATE, 238 | GNUNET_DISK_OPEN_TRUNCATE,
241 GNUNET_DISK_PERM_USER_READ | 239 GNUNET_DISK_PERM_USER_READ |
242 GNUNET_DISK_PERM_USER_WRITE); 240 GNUNET_DISK_PERM_USER_WRITE);
243 total = 0; 241 total = 0;
@@ -292,13 +290,13 @@ transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e)
292 m->uid |= htonl (GNUNET_STATISTICS_PERSIST_BIT); 290 m->uid |= htonl (GNUNET_STATISTICS_PERSIST_BIT);
293 m->value = GNUNET_htonll (e->value); 291 m->value = GNUNET_htonll (e->value);
294 size -= sizeof (struct GNUNET_STATISTICS_ReplyMessage); 292 size -= sizeof (struct GNUNET_STATISTICS_ReplyMessage);
295 GNUNET_assert (size == GNUNET_STRINGS_buffer_fill ((char *) &m[1], 293 GNUNET_assert (size ==
296 size, 294 GNUNET_STRINGS_buffer_fill ((char *) &m[1], size, 2,
297 2, e->service, e->name)); 295 e->service, e->name));
298#if DEBUG_STATISTICS 296#if DEBUG_STATISTICS
299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 297 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
300 "Transmitting value for `%s:%s' (%d): %llu\n", 298 "Transmitting value for `%s:%s' (%d): %llu\n", e->service,
301 e->service, e->name, e->persistent, e->value); 299 e->name, e->persistent, e->value);
302#endif 300#endif
303 GNUNET_SERVER_notification_context_unicast (nc, client, &m->header, 301 GNUNET_SERVER_notification_context_unicast (nc, client, &m->header,
304 GNUNET_NO); 302 GNUNET_NO);
@@ -312,9 +310,8 @@ transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e)
312static int 310static int
313matches (const struct StatsEntry *e, const char *service, const char *name) 311matches (const struct StatsEntry *e, const char *service, const char *name)
314{ 312{
315 return ((0 == strlen (service)) || 313 return ((0 == strlen (service)) || (0 == strcmp (service, e->service))) &&
316 (0 == strcmp (service, e->service))) 314 ((0 == strlen (name)) || (0 == strcmp (name, e->name)));
317 && ((0 == strlen (name)) || (0 == strcmp (name, e->name)));
318} 315}
319 316
320 317
@@ -350,8 +347,7 @@ make_client_entry (struct GNUNET_SERVER_Client *client)
350 * GNUNET_SYSERR to close it (signal serious error) 347 * GNUNET_SYSERR to close it (signal serious error)
351 */ 348 */
352static void 349static void
353handle_get (void *cls, 350handle_get (void *cls, struct GNUNET_SERVER_Client *client,
354 struct GNUNET_SERVER_Client *client,
355 const struct GNUNET_MessageHeader *message) 351 const struct GNUNET_MessageHeader *message)
356{ 352{
357 struct GNUNET_MessageHeader end; 353 struct GNUNET_MessageHeader end;
@@ -363,8 +359,9 @@ handle_get (void *cls,
363 if (client != NULL) 359 if (client != NULL)
364 make_client_entry (client); 360 make_client_entry (client);
365 size = ntohs (message->size) - sizeof (struct GNUNET_MessageHeader); 361 size = ntohs (message->size) - sizeof (struct GNUNET_MessageHeader);
366 if (size != GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1], 362 if (size !=
367 size, 2, &service, &name)) 363 GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1], size, 2,
364 &service, &name))
368 { 365 {
369 GNUNET_break (0); 366 GNUNET_break (0);
370 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 367 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -407,9 +404,8 @@ notify_change (struct StatsEntry *se)
407 wvm.wid = htonl (pos->wid); 404 wvm.wid = htonl (pos->wid);
408 wvm.reserved = htonl (0); 405 wvm.reserved = htonl (0);
409 wvm.value = GNUNET_htonll (se->value); 406 wvm.value = GNUNET_htonll (se->value);
410 GNUNET_SERVER_notification_context_unicast (nc, 407 GNUNET_SERVER_notification_context_unicast (nc, pos->client, &wvm.header,
411 pos->client, 408 GNUNET_NO);
412 &wvm.header, GNUNET_NO);
413 pos->last_value = se->value; 409 pos->last_value = se->value;
414 } 410 }
415 pos = pos->next; 411 pos = pos->next;
@@ -424,8 +420,7 @@ notify_change (struct StatsEntry *se)
424 * @param message the actual message 420 * @param message the actual message
425 */ 421 */
426static void 422static void
427handle_set (void *cls, 423handle_set (void *cls, struct GNUNET_SERVER_Client *client,
428 struct GNUNET_SERVER_Client *client,
429 const struct GNUNET_MessageHeader *message) 424 const struct GNUNET_MessageHeader *message)
430{ 425{
431 char *service; 426 char *service;
@@ -452,8 +447,9 @@ handle_set (void *cls,
452 size = msize - sizeof (struct GNUNET_STATISTICS_SetMessage); 447 size = msize - sizeof (struct GNUNET_STATISTICS_SetMessage);
453 msg = (const struct GNUNET_STATISTICS_SetMessage *) message; 448 msg = (const struct GNUNET_STATISTICS_SetMessage *) message;
454 449
455 if (size != GNUNET_STRINGS_buffer_tokenize ((const char *) &msg[1], 450 if (size !=
456 size, 2, &service, &name)) 451 GNUNET_STRINGS_buffer_tokenize ((const char *) &msg[1], size, 2, &service,
452 &name))
457 { 453 {
458 GNUNET_break (0); 454 GNUNET_break (0);
459 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 455 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -504,8 +500,8 @@ handle_set (void *cls,
504 } 500 }
505#if DEBUG_STATISTICS 501#if DEBUG_STATISTICS
506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
507 "Statistic `%s:%s' updated to value %llu.\n", 503 "Statistic `%s:%s' updated to value %llu.\n", service, name,
508 service, name, pos->value); 504 pos->value);
509#endif 505#endif
510 if (changed) 506 if (changed)
511 notify_change (pos); 507 notify_change (pos);
@@ -530,8 +526,8 @@ handle_set (void *cls,
530 start = pos; 526 start = pos;
531#if DEBUG_STATISTICS 527#if DEBUG_STATISTICS
532 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 528 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
533 "New statistic on `%s:%s' with value %llu created.\n", 529 "New statistic on `%s:%s' with value %llu created.\n", service,
534 service, name, pos->value); 530 name, pos->value);
535#endif 531#endif
536 GNUNET_SERVER_receive_done (client, GNUNET_OK); 532 GNUNET_SERVER_receive_done (client, GNUNET_OK);
537} 533}
@@ -545,8 +541,7 @@ handle_set (void *cls,
545 * @param message the actual message 541 * @param message the actual message
546 */ 542 */
547static void 543static void
548handle_watch (void *cls, 544handle_watch (void *cls, struct GNUNET_SERVER_Client *client,
549 struct GNUNET_SERVER_Client *client,
550 const struct GNUNET_MessageHeader *message) 545 const struct GNUNET_MessageHeader *message)
551{ 546{
552 char *service; 547 char *service;
@@ -567,8 +562,9 @@ handle_watch (void *cls,
567 return; 562 return;
568 } 563 }
569 size = msize - sizeof (struct GNUNET_MessageHeader); 564 size = msize - sizeof (struct GNUNET_MessageHeader);
570 if (size != GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1], 565 if (size !=
571 size, 2, &service, &name)) 566 GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1], size, 2,
567 &service, &name))
572 { 568 {
573 GNUNET_break (0); 569 GNUNET_break (0);
574 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 570 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -576,8 +572,8 @@ handle_watch (void *cls,
576 } 572 }
577#if DEBUG_STATISTICS 573#if DEBUG_STATISTICS
578 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 574 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
579 "Received request to watch statistic on `%s:%s'\n", 575 "Received request to watch statistic on `%s:%s'\n", service,
580 service, name); 576 name);
581#endif 577#endif
582 pos = start; 578 pos = start;
583 while (pos != NULL) 579 while (pos != NULL)
@@ -588,8 +584,9 @@ handle_watch (void *cls,
588 } 584 }
589 if (pos == NULL) 585 if (pos == NULL)
590 { 586 {
591 pos = GNUNET_malloc (sizeof (struct StatsEntry) + 587 pos =
592 sizeof (struct GNUNET_STATISTICS_SetMessage) + size); 588 GNUNET_malloc (sizeof (struct StatsEntry) +
589 sizeof (struct GNUNET_STATISTICS_SetMessage) + size);
593 pos->next = start; 590 pos->next = start;
594 pos->uid = uidgen++; 591 pos->uid = uidgen++;
595 pos->msg = (void *) &pos[1]; 592 pos->msg = (void *) &pos[1];
@@ -702,8 +699,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
702 * @param c configuration to use 699 * @param c configuration to use
703 */ 700 */
704static void 701static void
705run (void *cls, 702run (void *cls, struct GNUNET_SERVER_Handle *server,
706 struct GNUNET_SERVER_Handle *server,
707 const struct GNUNET_CONFIGURATION_Handle *c) 703 const struct GNUNET_CONFIGURATION_Handle *c)
708{ 704{
709 static const struct GNUNET_SERVER_MessageHandler handlers[] = { 705 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
@@ -717,8 +713,8 @@ run (void *cls,
717 nc = GNUNET_SERVER_notification_context_create (server, 16); 713 nc = GNUNET_SERVER_notification_context_create (server, 16);
718 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); 714 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
719 load (server); 715 load (server);
720 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 716 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
721 &shutdown_task, NULL); 717 NULL);
722} 718}
723 719
724 720
@@ -733,9 +729,7 @@ int
733main (int argc, char *const *argv) 729main (int argc, char *const *argv)
734{ 730{
735 return (GNUNET_OK == 731 return (GNUNET_OK ==
736 GNUNET_SERVICE_run (argc, 732 GNUNET_SERVICE_run (argc, argv, "statistics",
737 argv,
738 "statistics",
739 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; 733 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
740} 734}
741 735
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c
index 5267e38cf..80488958f 100644
--- a/src/statistics/gnunet-statistics.c
+++ b/src/statistics/gnunet-statistics.c
@@ -63,14 +63,11 @@ static int persistent;
63 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 63 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
64 */ 64 */
65static int 65static int
66printer (void *cls, 66printer (void *cls, const char *subsystem, const char *name, uint64_t value,
67 const char *subsystem, 67 int is_persistent)
68 const char *name, uint64_t value, int is_persistent)
69{ 68{
70 FPRINTF (stdout, 69 FPRINTF (stdout, "%s%-12s %-50s: %16llu\n", is_persistent ? "!" : " ",
71 "%s%-12s %-50s: %16llu\n", 70 subsystem, _(name), (unsigned long long) value);
72 is_persistent ? "!" : " ", subsystem, _(name),
73 (unsigned long long) value);
74 return GNUNET_OK; 71 return GNUNET_OK;
75} 72}
76 73
@@ -106,17 +103,16 @@ cleanup (void *cls, int success)
106 * @param cfg configuration 103 * @param cfg configuration
107 */ 104 */
108static void 105static void
109run (void *cls, 106run (void *cls, char *const *args, const char *cfgfile,
110 char *const *args, 107 const struct GNUNET_CONFIGURATION_Handle *cfg)
111 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
112{ 108{
113 struct GNUNET_STATISTICS_Handle *h; 109 struct GNUNET_STATISTICS_Handle *h;
114 unsigned long long val; 110 unsigned long long val;
115 111
116 if (args[0] != NULL) 112 if (args[0] != NULL)
117 { 113 {
118 if ((1 != SSCANF (args[0], "%llu", &val)) || 114 if ((1 != SSCANF (args[0], "%llu", &val)) || (subsystem == NULL) ||
119 (subsystem == NULL) || (name == NULL)) 115 (name == NULL))
120 { 116 {
121 FPRINTF (stderr, _("Invalid argument `%s'\n"), args[0]); 117 FPRINTF (stderr, _("Invalid argument `%s'\n"), args[0]);
122 ret = 1; 118 ret = 1;
@@ -138,9 +134,9 @@ run (void *cls,
138 ret = 1; 134 ret = 1;
139 return; 135 return;
140 } 136 }
141 if (NULL == GNUNET_STATISTICS_get (h, 137 if (NULL ==
142 subsystem, name, GET_TIMEOUT, &cleanup, 138 GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, &cleanup,
143 &printer, h)) 139 &printer, h))
144 cleanup (h, GNUNET_SYSERR); 140 cleanup (h, GNUNET_SYSERR);
145} 141}
146 142
@@ -167,9 +163,7 @@ main (int argc, char *const *argv)
167 GNUNET_GETOPT_OPTION_END 163 GNUNET_GETOPT_OPTION_END
168 }; 164 };
169 return (GNUNET_OK == 165 return (GNUNET_OK ==
170 GNUNET_PROGRAM_run (argc, 166 GNUNET_PROGRAM_run (argc, argv, "gnunet-statistics [options [value]]",
171 argv,
172 "gnunet-statistics [options [value]]",
173 gettext_noop 167 gettext_noop
174 ("Print statistics about GNUnet operations."), 168 ("Print statistics about GNUnet operations."),
175 options, &run, NULL)) ? ret : 1; 169 options, &run, NULL)) ? ret : 1;
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c
index a76f83db1..f4a71cc21 100644
--- a/src/statistics/statistics_api.c
+++ b/src/statistics/statistics_api.c
@@ -256,8 +256,8 @@ static void
256insert_ai (struct GNUNET_STATISTICS_Handle *h, 256insert_ai (struct GNUNET_STATISTICS_Handle *h,
257 struct GNUNET_STATISTICS_GetHandle *ai) 257 struct GNUNET_STATISTICS_GetHandle *ai)
258{ 258{
259 GNUNET_CONTAINER_DLL_insert_after (h->action_head, 259 GNUNET_CONTAINER_DLL_insert_after (h->action_head, h->action_tail,
260 h->action_tail, h->action_tail, ai); 260 h->action_tail, ai);
261 if (h->action_head == ai) 261 if (h->action_head == ai)
262 schedule_action (h); 262 schedule_action (h);
263} 263}
@@ -388,21 +388,20 @@ process_message (struct GNUNET_STATISTICS_Handle *h,
388 } 388 }
389 smsg = (const struct GNUNET_STATISTICS_ReplyMessage *) msg; 389 smsg = (const struct GNUNET_STATISTICS_ReplyMessage *) msg;
390 size -= sizeof (struct GNUNET_STATISTICS_ReplyMessage); 390 size -= sizeof (struct GNUNET_STATISTICS_ReplyMessage);
391 if (size != GNUNET_STRINGS_buffer_tokenize ((const char *) &smsg[1], 391 if (size !=
392 size, 2, &service, &name)) 392 GNUNET_STRINGS_buffer_tokenize ((const char *) &smsg[1], size, 2,
393 &service, &name))
393 { 394 {
394 GNUNET_break (0); 395 GNUNET_break (0);
395 return GNUNET_SYSERR; 396 return GNUNET_SYSERR;
396 } 397 }
397#if DEBUG_STATISTICS 398#if DEBUG_STATISTICS
398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
399 "Received valid statistic on `%s:%s': %llu\n", 400 "Received valid statistic on `%s:%s': %llu\n", service, name,
400 service, name, GNUNET_ntohll (smsg->value)); 401 GNUNET_ntohll (smsg->value));
401#endif 402#endif
402 if (GNUNET_OK != 403 if (GNUNET_OK !=
403 h->current->proc (h->current->cls, 404 h->current->proc (h->current->cls, service, name,
404 service,
405 name,
406 GNUNET_ntohll (smsg->value), 405 GNUNET_ntohll (smsg->value),
407 0 != 406 0 !=
408 (ntohl (smsg->uid) & GNUNET_STATISTICS_PERSIST_BIT))) 407 (ntohl (smsg->uid) & GNUNET_STATISTICS_PERSIST_BIT)))
@@ -442,9 +441,7 @@ process_watch_value (struct GNUNET_STATISTICS_Handle *h,
442 return GNUNET_SYSERR; 441 return GNUNET_SYSERR;
443 } 442 }
444 w = h->watches[wid]; 443 w = h->watches[wid];
445 (void) w->proc (w->proc_cls, 444 (void) w->proc (w->proc_cls, w->subsystem, w->name,
446 w->subsystem,
447 w->name,
448 GNUNET_ntohll (wvm->value), 445 GNUNET_ntohll (wvm->value),
449 0 != (ntohl (wvm->flags) & GNUNET_STATISTICS_PERSIST_BIT)); 446 0 != (ntohl (wvm->flags) & GNUNET_STATISTICS_PERSIST_BIT));
450 return GNUNET_OK; 447 return GNUNET_OK;
@@ -485,8 +482,8 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg)
485 h->backoff = GNUNET_TIME_UNIT_MILLISECONDS; 482 h->backoff = GNUNET_TIME_UNIT_MILLISECONDS;
486 if (h->watches_size > 0) 483 if (h->watches_size > 0)
487 { 484 {
488 GNUNET_CLIENT_receive (h->client, 485 GNUNET_CLIENT_receive (h->client, &receive_stats, h,
489 &receive_stats, h, GNUNET_TIME_UNIT_FOREVER_REL); 486 GNUNET_TIME_UNIT_FOREVER_REL);
490 } 487 }
491 else 488 else
492 { 489 {
@@ -502,11 +499,9 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg)
502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 499 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
503 "Processing VALUE done, now reading more\n"); 500 "Processing VALUE done, now reading more\n");
504#endif 501#endif
505 GNUNET_CLIENT_receive (h->client, 502 GNUNET_CLIENT_receive (h->client, &receive_stats, h,
506 &receive_stats, 503 GNUNET_TIME_absolute_get_remaining (h->current->
507 h, 504 timeout));
508 GNUNET_TIME_absolute_get_remaining
509 (h->current->timeout));
510 h->backoff = GNUNET_TIME_UNIT_MILLISECONDS; 505 h->backoff = GNUNET_TIME_UNIT_MILLISECONDS;
511 return; 506 return;
512 } 507 }
@@ -517,8 +512,8 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg)
517 { 512 {
518 h->backoff = GNUNET_TIME_UNIT_MILLISECONDS; 513 h->backoff = GNUNET_TIME_UNIT_MILLISECONDS;
519 GNUNET_assert (h->watches_size > 0); 514 GNUNET_assert (h->watches_size > 0);
520 GNUNET_CLIENT_receive (h->client, 515 GNUNET_CLIENT_receive (h->client, &receive_stats, h,
521 &receive_stats, h, GNUNET_TIME_UNIT_FOREVER_REL); 516 GNUNET_TIME_UNIT_FOREVER_REL);
522 return; 517 return;
523 } 518 }
524 GNUNET_break (0); 519 GNUNET_break (0);
@@ -566,9 +561,7 @@ transmit_get (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf)
566 hdr->size = htons (msize); 561 hdr->size = htons (msize);
567 hdr->type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_GET); 562 hdr->type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_GET);
568 GNUNET_assert (slen1 + slen2 == 563 GNUNET_assert (slen1 + slen2 ==
569 GNUNET_STRINGS_buffer_fill ((char *) &hdr[1], 564 GNUNET_STRINGS_buffer_fill ((char *) &hdr[1], slen1 + slen2, 2,
570 slen1 + slen2,
571 2,
572 handle->current->subsystem, 565 handle->current->subsystem,
573 handle->current->name)); 566 handle->current->name));
574 if (!handle->receiving) 567 if (!handle->receiving)
@@ -578,11 +571,9 @@ transmit_get (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf)
578 "Transmission of GET done, now reading response\n"); 571 "Transmission of GET done, now reading response\n");
579#endif 572#endif
580 handle->receiving = GNUNET_YES; 573 handle->receiving = GNUNET_YES;
581 GNUNET_CLIENT_receive (handle->client, 574 GNUNET_CLIENT_receive (handle->client, &receive_stats, handle,
582 &receive_stats, 575 GNUNET_TIME_absolute_get_remaining (handle->current->
583 handle, 576 timeout));
584 GNUNET_TIME_absolute_get_remaining (handle->
585 current->timeout));
586 } 577 }
587 return msize; 578 return msize;
588} 579}
@@ -611,8 +602,8 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf)
611 return 0; 602 return 0;
612 } 603 }
613#if DEBUG_STATISTICS 604#if DEBUG_STATISTICS
614 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 605 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting watch request for `%s'\n",
615 "Transmitting watch request for `%s'\n", handle->current->name); 606 handle->current->name);
616#endif 607#endif
617 slen1 = strlen (handle->current->subsystem) + 1; 608 slen1 = strlen (handle->current->subsystem) + 1;
618 slen2 = strlen (handle->current->name) + 1; 609 slen2 = strlen (handle->current->name) + 1;
@@ -622,17 +613,14 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf)
622 hdr->size = htons (msize); 613 hdr->size = htons (msize);
623 hdr->type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_WATCH); 614 hdr->type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_WATCH);
624 GNUNET_assert (slen1 + slen2 == 615 GNUNET_assert (slen1 + slen2 ==
625 GNUNET_STRINGS_buffer_fill ((char *) &hdr[1], 616 GNUNET_STRINGS_buffer_fill ((char *) &hdr[1], slen1 + slen2, 2,
626 slen1 + slen2,
627 2,
628 handle->current->subsystem, 617 handle->current->subsystem,
629 handle->current->name)); 618 handle->current->name));
630 if (GNUNET_YES != handle->receiving) 619 if (GNUNET_YES != handle->receiving)
631 { 620 {
632 handle->receiving = GNUNET_YES; 621 handle->receiving = GNUNET_YES;
633 GNUNET_CLIENT_receive (handle->client, 622 GNUNET_CLIENT_receive (handle->client, &receive_stats, handle,
634 &receive_stats, 623 GNUNET_TIME_UNIT_FOREVER_REL);
635 handle, GNUNET_TIME_UNIT_FOREVER_REL);
636 } 624 }
637 finish (handle, GNUNET_OK); 625 finish (handle, GNUNET_OK);
638 return msize; 626 return msize;
@@ -675,9 +663,7 @@ transmit_set (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf)
675 if (handle->current->type == ACTION_UPDATE) 663 if (handle->current->type == ACTION_UPDATE)
676 r->flags |= htonl (GNUNET_STATISTICS_SETFLAG_RELATIVE); 664 r->flags |= htonl (GNUNET_STATISTICS_SETFLAG_RELATIVE);
677 GNUNET_assert (slen + nlen == 665 GNUNET_assert (slen + nlen ==
678 GNUNET_STRINGS_buffer_fill ((char *) &r[1], 666 GNUNET_STRINGS_buffer_fill ((char *) &r[1], slen + nlen, 2,
679 slen + nlen,
680 2,
681 handle->current->subsystem, 667 handle->current->subsystem,
682 handle->current->name)); 668 handle->current->name));
683 finish (handle, GNUNET_OK); 669 finish (handle, GNUNET_OK);
@@ -809,11 +795,10 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first)
809 if ((h->current != NULL) && (h->th == NULL)) 795 if ((h->current != NULL) && (h->th == NULL))
810 { 796 {
811 timeout = GNUNET_TIME_absolute_get_remaining (h->current->timeout); 797 timeout = GNUNET_TIME_absolute_get_remaining (h->current->timeout);
812 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, 798 h->th =
813 h->current->msize, 799 GNUNET_CLIENT_notify_transmit_ready (h->client, h->current->msize,
814 timeout, 800 timeout, GNUNET_YES,
815 GNUNET_YES, 801 &transmit_action, h);
816 &transmit_action, h);
817 GNUNET_assert (NULL != h->th); 802 GNUNET_assert (NULL != h->th);
818 } 803 }
819 if (h->th != NULL) 804 if (h->th != NULL)
@@ -870,11 +855,11 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h)
870 return; /* action already pending */ 855 return; /* action already pending */
871 if (GNUNET_YES != try_connect (h)) 856 if (GNUNET_YES != try_connect (h))
872 { 857 {
873 h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->backoff, 858 h->backoff_task =
874 &finish_task, h); 859 GNUNET_SCHEDULER_add_delayed (h->backoff, &finish_task, h);
875 h->backoff = GNUNET_TIME_relative_multiply (h->backoff, 2); 860 h->backoff = GNUNET_TIME_relative_multiply (h->backoff, 2);
876 h->backoff = GNUNET_TIME_relative_min (h->backoff, 861 h->backoff =
877 GNUNET_CONSTANTS_SERVICE_TIMEOUT); 862 GNUNET_TIME_relative_min (h->backoff, GNUNET_CONSTANTS_SERVICE_TIMEOUT);
878 return; 863 return;
879 } 864 }
880 865
@@ -892,11 +877,10 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h)
892 GNUNET_CONTAINER_DLL_remove (h->action_head, h->action_tail, h->current); 877 GNUNET_CONTAINER_DLL_remove (h->action_head, h->action_tail, h->current);
893 timeout = GNUNET_TIME_absolute_get_remaining (h->current->timeout); 878 timeout = GNUNET_TIME_absolute_get_remaining (h->current->timeout);
894 if (NULL == 879 if (NULL ==
895 (h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, 880 (h->th =
896 h->current->msize, 881 GNUNET_CLIENT_notify_transmit_ready (h->client, h->current->msize,
897 timeout, 882 timeout, GNUNET_YES,
898 GNUNET_YES, 883 &transmit_action, h)))
899 &transmit_action, h)))
900 { 884 {
901#if DEBUG_STATISTICS 885#if DEBUG_STATISTICS
902 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 886 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -922,8 +906,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h)
922 */ 906 */
923struct GNUNET_STATISTICS_GetHandle * 907struct GNUNET_STATISTICS_GetHandle *
924GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle, 908GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle,
925 const char *subsystem, 909 const char *subsystem, const char *name,
926 const char *name,
927 struct GNUNET_TIME_Relative timeout, 910 struct GNUNET_TIME_Relative timeout,
928 GNUNET_STATISTICS_Callback cont, 911 GNUNET_STATISTICS_Callback cont,
929 GNUNET_STATISTICS_Iterator proc, void *cls) 912 GNUNET_STATISTICS_Iterator proc, void *cls)
@@ -1005,8 +988,7 @@ GNUNET_STATISTICS_get_cancel (struct GNUNET_STATISTICS_GetHandle *gh)
1005 */ 988 */
1006int 989int
1007GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, 990GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle,
1008 const char *subsystem, 991 const char *subsystem, const char *name,
1009 const char *name,
1010 GNUNET_STATISTICS_Iterator proc, void *proc_cls) 992 GNUNET_STATISTICS_Iterator proc, void *proc_cls)
1011{ 993{
1012 struct GNUNET_STATISTICS_WatchEntry *w; 994 struct GNUNET_STATISTICS_WatchEntry *w;
@@ -1025,8 +1007,7 @@ GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle,
1025 1007
1026 1008
1027static void 1009static void
1028add_setter_action (struct GNUNET_STATISTICS_Handle *h, 1010add_setter_action (struct GNUNET_STATISTICS_Handle *h, const char *name,
1029 const char *name,
1030 int make_persistent, uint64_t value, enum ActionType type) 1011 int make_persistent, uint64_t value, enum ActionType type)
1031{ 1012{
1032 struct GNUNET_STATISTICS_GetHandle *ai; 1013 struct GNUNET_STATISTICS_GetHandle *ai;
@@ -1051,8 +1032,8 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h,
1051 while (ai != NULL) 1032 while (ai != NULL)
1052 { 1033 {
1053 if ((0 == strcmp (ai->subsystem, h->subsystem)) && 1034 if ((0 == strcmp (ai->subsystem, h->subsystem)) &&
1054 (0 == strcmp (ai->name, name)) && 1035 (0 == strcmp (ai->name, name)) && ((ai->type == ACTION_UPDATE) ||
1055 ((ai->type == ACTION_UPDATE) || (ai->type == ACTION_SET))) 1036 (ai->type == ACTION_SET)))
1056 { 1037 {
1057 if (ai->type == ACTION_SET) 1038 if (ai->type == ACTION_SET)
1058 { 1039 {
@@ -1146,8 +1127,8 @@ GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
1146 if (delta == 0) 1127 if (delta == 0)
1147 return; 1128 return;
1148 GNUNET_assert (GNUNET_NO == handle->do_destroy); 1129 GNUNET_assert (GNUNET_NO == handle->do_destroy);
1149 add_setter_action (handle, name, make_persistent, 1130 add_setter_action (handle, name, make_persistent, (uint64_t) delta,
1150 (uint64_t) delta, ACTION_UPDATE); 1131 ACTION_UPDATE);
1151} 1132}
1152 1133
1153 1134
diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c
index de05d6c69..39a71a79e 100644
--- a/src/statistics/test_statistics_api.c
+++ b/src/statistics/test_statistics_api.c
@@ -34,12 +34,10 @@
34#define START_SERVICE GNUNET_YES 34#define START_SERVICE GNUNET_YES
35 35
36static int 36static int
37check_1 (void *cls, 37check_1 (void *cls, const char *subsystem, const char *name, uint64_t value,
38 const char *subsystem, 38 int is_persistent)
39 const char *name, uint64_t value, int is_persistent)
40{ 39{
41 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 40 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received value %llu for `%s:%s\n",
42 "Received value %llu for `%s:%s\n",
43 (unsigned long long) value, subsystem, name); 41 (unsigned long long) value, subsystem, name);
44 GNUNET_assert (0 == strcmp (name, "test-1")); 42 GNUNET_assert (0 == strcmp (name, "test-1"));
45 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api")); 43 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api"));
@@ -49,12 +47,10 @@ check_1 (void *cls,
49} 47}
50 48
51static int 49static int
52check_2 (void *cls, 50check_2 (void *cls, const char *subsystem, const char *name, uint64_t value,
53 const char *subsystem, 51 int is_persistent)
54 const char *name, uint64_t value, int is_persistent)
55{ 52{
56 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 53 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received value %llu for `%s:%s\n",
57 "Received value %llu for `%s:%s\n",
58 (unsigned long long) value, subsystem, name); 54 (unsigned long long) value, subsystem, name);
59 GNUNET_assert (0 == strcmp (name, "test-2")); 55 GNUNET_assert (0 == strcmp (name, "test-2"));
60 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api")); 56 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api"));
@@ -64,12 +60,10 @@ check_2 (void *cls,
64} 60}
65 61
66static int 62static int
67check_3 (void *cls, 63check_3 (void *cls, const char *subsystem, const char *name, uint64_t value,
68 const char *subsystem, 64 int is_persistent)
69 const char *name, uint64_t value, int is_persistent)
70{ 65{
71 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 66 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received value %llu for `%s:%s\n",
72 "Received value %llu for `%s:%s\n",
73 (unsigned long long) value, subsystem, name); 67 (unsigned long long) value, subsystem, name);
74 GNUNET_assert (0 == strcmp (name, "test-3")); 68 GNUNET_assert (0 == strcmp (name, "test-3"));
75 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api")); 69 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api"));
@@ -102,9 +96,8 @@ next (void *cls, int success)
102} 96}
103 97
104static void 98static void
105run (void *cls, 99run (void *cls, char *const *args, const char *cfgfile,
106 char *const *args, 100 const struct GNUNET_CONFIGURATION_Handle *cfg)
107 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
108{ 101{
109 h = GNUNET_STATISTICS_create ("test-statistics-api", cfg); 102 h = GNUNET_STATISTICS_create ("test-statistics-api", cfg);
110 GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO); 103 GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO);
@@ -119,9 +112,8 @@ run (void *cls,
119} 112}
120 113
121static void 114static void
122run_more (void *cls, 115run_more (void *cls, char *const *args, const char *cfgfile,
123 char *const *args, 116 const struct GNUNET_CONFIGURATION_Handle *cfg)
124 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
125{ 117{
126 h = GNUNET_STATISTICS_create ("test-statistics-api", cfg); 118 h = GNUNET_STATISTICS_create ("test-statistics-api", cfg);
127 GNUNET_break (NULL != 119 GNUNET_break (NULL !=
@@ -151,16 +143,17 @@ check ()
151#if START_SERVICE 143#if START_SERVICE
152 struct GNUNET_OS_Process *proc; 144 struct GNUNET_OS_Process *proc;
153 145
154 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", 146 proc =
155 "gnunet-service-statistics", 147 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
148 "gnunet-service-statistics",
156#if DEBUG_STATISTICS 149#if DEBUG_STATISTICS
157 "-L", "DEBUG", 150 "-L", "DEBUG",
158#endif 151#endif
159 "-c", "test_statistics_api_data.conf", NULL); 152 "-c", "test_statistics_api_data.conf", NULL);
160#endif 153#endif
161 GNUNET_assert (NULL != proc); 154 GNUNET_assert (NULL != proc);
162 GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", 155 GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options, &run,
163 options, &run, &ok); 156 &ok);
164#if START_SERVICE 157#if START_SERVICE
165 if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) 158 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
166 { 159 {
@@ -176,15 +169,16 @@ check ()
176 ok = 1; 169 ok = 1;
177#if START_SERVICE 170#if START_SERVICE
178 /* restart to check persistence! */ 171 /* restart to check persistence! */
179 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", 172 proc =
180 "gnunet-service-statistics", 173 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
174 "gnunet-service-statistics",
181#if DEBUG_STATISTICS 175#if DEBUG_STATISTICS
182 "-L", "DEBUG", 176 "-L", "DEBUG",
183#endif 177#endif
184 "-c", "test_statistics_api_data.conf", NULL); 178 "-c", "test_statistics_api_data.conf", NULL);
185#endif 179#endif
186 GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", 180 GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options,
187 options, &run_more, &ok); 181 &run_more, &ok);
188#if START_SERVICE 182#if START_SERVICE
189 if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) 183 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
190 { 184 {
diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c
index 87190a99a..eb739b752 100644
--- a/src/statistics/test_statistics_api_loop.c
+++ b/src/statistics/test_statistics_api_loop.c
@@ -36,9 +36,8 @@
36#define ROUNDS (1024 * 1024) 36#define ROUNDS (1024 * 1024)
37 37
38static int 38static int
39check_1 (void *cls, 39check_1 (void *cls, const char *subsystem, const char *name, uint64_t value,
40 const char *subsystem, 40 int is_persistent)
41 const char *name, uint64_t value, int is_persistent)
42{ 41{
43 GNUNET_assert (0 == strcmp (name, "test-0")); 42 GNUNET_assert (0 == strcmp (name, "test-0"));
44 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api-loop")); 43 GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api-loop"));
@@ -59,9 +58,8 @@ next (void *cls, int success)
59} 58}
60 59
61static void 60static void
62run (void *cls, 61run (void *cls, char *const *args, const char *cfgfile,
63 char *const *args, 62 const struct GNUNET_CONFIGURATION_Handle *cfg)
64 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
65{ 63{
66 int i; 64 int i;
67 char name[128]; 65 char name[128];
@@ -98,16 +96,17 @@ check ()
98#if START_SERVICE 96#if START_SERVICE
99 struct GNUNET_OS_Process *proc; 97 struct GNUNET_OS_Process *proc;
100 98
101 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", 99 proc =
102 "gnunet-service-statistics", 100 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
101 "gnunet-service-statistics",
103#if DEBUG_STATISTICS 102#if DEBUG_STATISTICS
104 "-L", "DEBUG", 103 "-L", "DEBUG",
105#endif 104#endif
106 "-c", "test_statistics_api_data.conf", NULL); 105 "-c", "test_statistics_api_data.conf", NULL);
107#endif 106#endif
108 GNUNET_assert (NULL != proc); 107 GNUNET_assert (NULL != proc);
109 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", 108 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run,
110 options, &run, &ok); 109 &ok);
111#if START_SERVICE 110#if START_SERVICE
112 if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) 111 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
113 { 112 {
diff --git a/src/statistics/test_statistics_api_watch.c b/src/statistics/test_statistics_api_watch.c
index 72cb27ecf..cea495836 100644
--- a/src/statistics/test_statistics_api_watch.c
+++ b/src/statistics/test_statistics_api_watch.c
@@ -63,9 +63,8 @@ normal_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
63 63
64 64
65static int 65static int
66watch_1 (void *cls, 66watch_1 (void *cls, const char *subsystem, const char *name, uint64_t value,
67 const char *subsystem, 67 int is_persistent)
68 const char *name, uint64_t value, int is_persistent)
69{ 68{
70 GNUNET_assert (value == 42); 69 GNUNET_assert (value == 42);
71 GNUNET_assert (0 == strcmp (name, "test-1")); 70 GNUNET_assert (0 == strcmp (name, "test-1"));
@@ -80,9 +79,8 @@ watch_1 (void *cls,
80 79
81 80
82static int 81static int
83watch_2 (void *cls, 82watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value,
84 const char *subsystem, 83 int is_persistent)
85 const char *name, uint64_t value, int is_persistent)
86{ 84{
87 GNUNET_assert (value == 43); 85 GNUNET_assert (value == 43);
88 GNUNET_assert (0 == strcmp (name, "test-2")); 86 GNUNET_assert (0 == strcmp (name, "test-2"));
@@ -97,24 +95,22 @@ watch_2 (void *cls,
97 95
98 96
99static void 97static void
100run (void *cls, 98run (void *cls, char *const *args, const char *cfgfile,
101 char *const *args, 99 const struct GNUNET_CONFIGURATION_Handle *cfg)
102 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
103{ 100{
104 h = GNUNET_STATISTICS_create ("dummy", cfg); 101 h = GNUNET_STATISTICS_create ("dummy", cfg);
105 GNUNET_assert (GNUNET_OK == 102 GNUNET_assert (GNUNET_OK ==
106 GNUNET_STATISTICS_watch (h, 103 GNUNET_STATISTICS_watch (h, "test-statistics-api-watch",
107 "test-statistics-api-watch",
108 "test-1", &watch_1, NULL)); 104 "test-1", &watch_1, NULL));
109 GNUNET_assert (GNUNET_OK == 105 GNUNET_assert (GNUNET_OK ==
110 GNUNET_STATISTICS_watch (h, 106 GNUNET_STATISTICS_watch (h, "test-statistics-api-watch",
111 "test-statistics-api-watch",
112 "test-2", &watch_2, NULL)); 107 "test-2", &watch_2, NULL));
113 h2 = GNUNET_STATISTICS_create ("test-statistics-api-watch", cfg); 108 h2 = GNUNET_STATISTICS_create ("test-statistics-api-watch", cfg);
114 GNUNET_STATISTICS_set (h2, "test-1", 42, GNUNET_NO); 109 GNUNET_STATISTICS_set (h2, "test-1", 42, GNUNET_NO);
115 GNUNET_STATISTICS_set (h2, "test-2", 43, GNUNET_NO); 110 GNUNET_STATISTICS_set (h2, "test-2", 43, GNUNET_NO);
116 shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 111 shutdown_task =
117 &force_shutdown, NULL); 112 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &force_shutdown,
113 NULL);
118} 114}
119 115
120 116
@@ -132,17 +128,18 @@ check ()
132#if START_SERVICE 128#if START_SERVICE
133 struct GNUNET_OS_Process *proc; 129 struct GNUNET_OS_Process *proc;
134 130
135 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", 131 proc =
136 "gnunet-service-statistics", 132 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
133 "gnunet-service-statistics",
137#if VERBOSE 134#if VERBOSE
138 "-L", "DEBUG", 135 "-L", "DEBUG",
139#endif 136#endif
140 "-c", "test_statistics_api_data.conf", NULL); 137 "-c", "test_statistics_api_data.conf", NULL);
141#endif 138#endif
142 GNUNET_assert (NULL != proc); 139 GNUNET_assert (NULL != proc);
143 ok = 3; 140 ok = 3;
144 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", 141 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run,
145 options, &run, NULL); 142 NULL);
146#if START_SERVICE 143#if START_SERVICE
147 if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) 144 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
148 { 145 {