diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-04 20:59:41 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-04 20:59:41 +0000 |
commit | fa2373ff7a4291216be7c00f76e276ee60aec654 (patch) | |
tree | 7f5da264095f18358b3abe772d88498ba6627407 /src/statistics | |
parent | 6cdff36159de7a4fe5bc31564cc7dc3a2f94b0ed (diff) | |
download | gnunet-fa2373ff7a4291216be7c00f76e276ee60aec654.tar.gz gnunet-fa2373ff7a4291216be7c00f76e276ee60aec654.zip |
make gnunet-service-statistics not exit on external shutdown signal as long as there are connected clients to be managed
Diffstat (limited to 'src/statistics')
-rw-r--r-- | src/statistics/gnunet-service-statistics.c | 157 | ||||
-rw-r--r-- | src/statistics/statistics.h | 1 | ||||
-rw-r--r-- | src/statistics/statistics_api.c | 28 |
3 files changed, 111 insertions, 75 deletions
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index a890d6d8e..c57013987 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c | |||
@@ -41,14 +41,29 @@ | |||
41 | struct WatchEntry | 41 | struct WatchEntry |
42 | { | 42 | { |
43 | 43 | ||
44 | /** | ||
45 | * Watch entries are kept in a linked list. | ||
46 | */ | ||
44 | struct WatchEntry *next; | 47 | struct WatchEntry *next; |
45 | 48 | ||
49 | /** | ||
50 | * Watch entries are kept in a linked list. | ||
51 | */ | ||
46 | struct WatchEntry *prev; | 52 | struct WatchEntry *prev; |
47 | 53 | ||
54 | /** | ||
55 | * For which client is this watch entry? | ||
56 | */ | ||
48 | struct GNUNET_SERVER_Client *client; | 57 | struct GNUNET_SERVER_Client *client; |
49 | 58 | ||
59 | /** | ||
60 | * Last value we communicated to the client for this watch entry. | ||
61 | */ | ||
50 | uint64_t last_value; | 62 | uint64_t last_value; |
51 | 63 | ||
64 | /** | ||
65 | * Unique watch number for this client and this watched value. | ||
66 | */ | ||
52 | uint32_t wid; | 67 | uint32_t wid; |
53 | 68 | ||
54 | }; | 69 | }; |
@@ -59,13 +74,24 @@ struct WatchEntry | |||
59 | */ | 74 | */ |
60 | struct ClientEntry | 75 | struct ClientEntry |
61 | { | 76 | { |
62 | 77 | /** | |
78 | * Clients are kept in a linked list. | ||
79 | */ | ||
63 | struct ClientEntry *next; | 80 | struct ClientEntry *next; |
64 | 81 | ||
82 | /** | ||
83 | * Clients are kept in a linked list. | ||
84 | */ | ||
65 | struct ClientEntry *prev; | 85 | struct ClientEntry *prev; |
66 | 86 | ||
87 | /** | ||
88 | * Corresponding server handle. | ||
89 | */ | ||
67 | struct GNUNET_SERVER_Client *client; | 90 | struct GNUNET_SERVER_Client *client; |
68 | 91 | ||
92 | /** | ||
93 | * Maximum watch ID used by this client so far. | ||
94 | */ | ||
69 | uint32_t max_wid; | 95 | uint32_t max_wid; |
70 | 96 | ||
71 | }; | 97 | }; |
@@ -138,11 +164,22 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
138 | */ | 164 | */ |
139 | static struct StatsEntry *start; | 165 | static struct StatsEntry *start; |
140 | 166 | ||
167 | /** | ||
168 | * Head of linked list of connected clients. | ||
169 | */ | ||
141 | static struct ClientEntry *client_head; | 170 | static struct ClientEntry *client_head; |
142 | 171 | ||
172 | /** | ||
173 | * Tail of linked list of connected clients. | ||
174 | */ | ||
143 | static struct ClientEntry *client_tail; | 175 | static struct ClientEntry *client_tail; |
144 | 176 | ||
145 | /** | 177 | /** |
178 | * Handle to our server. | ||
179 | */ | ||
180 | static struct GNUNET_SERVER_Handle *srv; | ||
181 | |||
182 | /** | ||
146 | * Our notification context. | 183 | * Our notification context. |
147 | */ | 184 | */ |
148 | static struct GNUNET_SERVER_NotificationContext *nc; | 185 | static struct GNUNET_SERVER_NotificationContext *nc; |
@@ -152,7 +189,19 @@ static struct GNUNET_SERVER_NotificationContext *nc; | |||
152 | */ | 189 | */ |
153 | static uint32_t uidgen; | 190 | static uint32_t uidgen; |
154 | 191 | ||
192 | /** | ||
193 | * Set to YES if we are shutting down as soon as possible. | ||
194 | */ | ||
195 | static int in_shutdown; | ||
196 | |||
155 | 197 | ||
198 | /** | ||
199 | * Inject a message to our server with a client of 'NULL'. | ||
200 | * | ||
201 | * @param cls the 'struct GNUNET_SERVER_Handle' | ||
202 | * @param client unused | ||
203 | * @param msg message to inject | ||
204 | */ | ||
156 | static void | 205 | static void |
157 | inject_message (void *cls, void *client, const struct GNUNET_MessageHeader *msg) | 206 | inject_message (void *cls, void *client, const struct GNUNET_MessageHeader *msg) |
158 | { | 207 | { |
@@ -219,6 +268,7 @@ load (struct GNUNET_SERVER_Handle *server) | |||
219 | GNUNET_free (fn); | 268 | GNUNET_free (fn); |
220 | } | 269 | } |
221 | 270 | ||
271 | |||
222 | /** | 272 | /** |
223 | * Write persistent statistics to disk. | 273 | * Write persistent statistics to disk. |
224 | */ | 274 | */ |
@@ -272,6 +322,9 @@ save () | |||
272 | 322 | ||
273 | /** | 323 | /** |
274 | * Transmit the given stats value. | 324 | * Transmit the given stats value. |
325 | * | ||
326 | * @param client receiver of the value | ||
327 | * @param e value to transmit | ||
275 | */ | 328 | */ |
276 | static void | 329 | static void |
277 | transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e) | 330 | transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e) |
@@ -294,11 +347,9 @@ transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e) | |||
294 | GNUNET_assert (size == | 347 | GNUNET_assert (size == |
295 | GNUNET_STRINGS_buffer_fill ((char *) &m[1], size, 2, | 348 | GNUNET_STRINGS_buffer_fill ((char *) &m[1], size, 2, |
296 | e->service, e->name)); | 349 | e->service, e->name)); |
297 | #if DEBUG_STATISTICS | ||
298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
299 | "Transmitting value for `%s:%s' (%d): %llu\n", e->service, | 351 | "Transmitting value for `%s:%s' (%d): %llu\n", e->service, |
300 | e->name, e->persistent, e->value); | 352 | e->name, e->persistent, e->value); |
301 | #endif | ||
302 | GNUNET_SERVER_notification_context_unicast (nc, client, &m->header, | 353 | GNUNET_SERVER_notification_context_unicast (nc, client, &m->header, |
303 | GNUNET_NO); | 354 | GNUNET_NO); |
304 | GNUNET_free (m); | 355 | GNUNET_free (m); |
@@ -307,6 +358,11 @@ transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e) | |||
307 | 358 | ||
308 | /** | 359 | /** |
309 | * Does this entry match the request? | 360 | * Does this entry match the request? |
361 | * | ||
362 | * @param e an entry | ||
363 | * @param service name of service to match | ||
364 | * @param name value to match | ||
365 | * @return 1 if they match, 0 if not | ||
310 | */ | 366 | */ |
311 | static int | 367 | static int |
312 | matches (const struct StatsEntry *e, const char *service, const char *name) | 368 | matches (const struct StatsEntry *e, const char *service, const char *name) |
@@ -316,6 +372,12 @@ matches (const struct StatsEntry *e, const char *service, const char *name) | |||
316 | } | 372 | } |
317 | 373 | ||
318 | 374 | ||
375 | /** | ||
376 | * Find a client entry for the given client handle, or create one. | ||
377 | * | ||
378 | * @param client handle to match | ||
379 | * @return corresponding client entry struct | ||
380 | */ | ||
319 | static struct ClientEntry * | 381 | static struct ClientEntry * |
320 | make_client_entry (struct GNUNET_SERVER_Client *client) | 382 | make_client_entry (struct GNUNET_SERVER_Client *client) |
321 | { | 383 | { |
@@ -368,18 +430,12 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client, | |||
368 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 430 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
369 | return; | 431 | return; |
370 | } | 432 | } |
371 | #if DEBUG_STATISTICS | ||
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
373 | "Received request for statistics on `%s:%s'\n", | 434 | "Received request for statistics on `%s:%s'\n", |
374 | strlen (service) ? service : "*", strlen (name) ? name : "*"); | 435 | strlen (service) ? service : "*", strlen (name) ? name : "*"); |
375 | #endif | 436 | for (pos = start; NULL != pos; pos = pos->next) |
376 | pos = start; | ||
377 | while (pos != NULL) | ||
378 | { | ||
379 | if (matches (pos, service, name)) | 437 | if (matches (pos, service, name)) |
380 | transmit (client, pos); | 438 | transmit (client, pos); |
381 | pos = pos->next; | ||
382 | } | ||
383 | end.size = htons (sizeof (struct GNUNET_MessageHeader)); | 439 | end.size = htons (sizeof (struct GNUNET_MessageHeader)); |
384 | end.type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_END); | 440 | end.type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_END); |
385 | GNUNET_SERVER_notification_context_unicast (nc, client, &end, GNUNET_NO); | 441 | GNUNET_SERVER_notification_context_unicast (nc, client, &end, GNUNET_NO); |
@@ -387,29 +443,31 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client, | |||
387 | } | 443 | } |
388 | 444 | ||
389 | 445 | ||
446 | /** | ||
447 | * Notify all clients listening about a change to a value. | ||
448 | * | ||
449 | * @param se value that changed | ||
450 | */ | ||
390 | static void | 451 | static void |
391 | notify_change (struct StatsEntry *se) | 452 | notify_change (struct StatsEntry *se) |
392 | { | 453 | { |
393 | struct GNUNET_STATISTICS_WatchValueMessage wvm; | 454 | struct GNUNET_STATISTICS_WatchValueMessage wvm; |
394 | struct WatchEntry *pos; | 455 | struct WatchEntry *pos; |
395 | 456 | ||
396 | pos = se->we_head; | 457 | for (pos = se->we_head; NULL != pos; pos = pos->next) |
397 | while (pos != NULL) | ||
398 | { | 458 | { |
399 | if (pos->last_value != se->value) | 459 | if (pos->last_value == se->value) |
400 | { | 460 | continue; |
401 | wvm.header.type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE); | 461 | wvm.header.type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE); |
402 | wvm.header.size = | 462 | wvm.header.size = |
403 | htons (sizeof (struct GNUNET_STATISTICS_WatchValueMessage)); | 463 | htons (sizeof (struct GNUNET_STATISTICS_WatchValueMessage)); |
404 | wvm.flags = htonl (se->persistent ? GNUNET_STATISTICS_PERSIST_BIT : 0); | 464 | wvm.flags = htonl (se->persistent ? GNUNET_STATISTICS_PERSIST_BIT : 0); |
405 | wvm.wid = htonl (pos->wid); | 465 | wvm.wid = htonl (pos->wid); |
406 | wvm.reserved = htonl (0); | 466 | wvm.reserved = htonl (0); |
407 | wvm.value = GNUNET_htonll (se->value); | 467 | wvm.value = GNUNET_htonll (se->value); |
408 | GNUNET_SERVER_notification_context_unicast (nc, pos->client, &wvm.header, | 468 | GNUNET_SERVER_notification_context_unicast (nc, pos->client, &wvm.header, |
409 | GNUNET_NO); | 469 | GNUNET_NO); |
410 | pos->last_value = se->value; | 470 | pos->last_value = se->value; |
411 | } | ||
412 | pos = pos->next; | ||
413 | } | 471 | } |
414 | } | 472 | } |
415 | 473 | ||
@@ -458,11 +516,9 @@ handle_set (void *cls, struct GNUNET_SERVER_Client *client, | |||
458 | } | 516 | } |
459 | flags = ntohl (msg->flags); | 517 | flags = ntohl (msg->flags); |
460 | value = GNUNET_ntohll (msg->value); | 518 | value = GNUNET_ntohll (msg->value); |
461 | #if DEBUG_STATISTICS | ||
462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
463 | "Received request to update statistic on `%s:%s' (%u) to/by %llu\n", | 520 | "Received request to update statistic on `%s:%s' (%u) to/by %llu\n", |
464 | service, name, (unsigned int) flags, (unsigned long long) value); | 521 | service, name, (unsigned int) flags, (unsigned long long) value); |
465 | #endif | ||
466 | pos = start; | 522 | pos = start; |
467 | prev = NULL; | 523 | prev = NULL; |
468 | while (pos != NULL) | 524 | while (pos != NULL) |
@@ -499,11 +555,9 @@ handle_set (void *cls, struct GNUNET_SERVER_Client *client, | |||
499 | pos->next = start; | 555 | pos->next = start; |
500 | start = pos; | 556 | start = pos; |
501 | } | 557 | } |
502 | #if DEBUG_STATISTICS | ||
503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 558 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
504 | "Statistic `%s:%s' updated to value %llu.\n", service, name, | 559 | "Statistic `%s:%s' updated to value %llu.\n", service, name, |
505 | pos->value); | 560 | pos->value); |
506 | #endif | ||
507 | if (changed) | 561 | if (changed) |
508 | notify_change (pos); | 562 | notify_change (pos); |
509 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 563 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -525,11 +579,9 @@ handle_set (void *cls, struct GNUNET_SERVER_Client *client, | |||
525 | pos->name = &pos->service[strlen (pos->service) + 1]; | 579 | pos->name = &pos->service[strlen (pos->service) + 1]; |
526 | 580 | ||
527 | start = pos; | 581 | start = pos; |
528 | #if DEBUG_STATISTICS | ||
529 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 582 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
530 | "New statistic on `%s:%s' with value %llu created.\n", service, | 583 | "New statistic on `%s:%s' with value %llu created.\n", service, |
531 | name, pos->value); | 584 | name, pos->value); |
532 | #endif | ||
533 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 585 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
534 | } | 586 | } |
535 | 587 | ||
@@ -571,11 +623,9 @@ handle_watch (void *cls, struct GNUNET_SERVER_Client *client, | |||
571 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 623 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
572 | return; | 624 | return; |
573 | } | 625 | } |
574 | #if DEBUG_STATISTICS | ||
575 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 626 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
576 | "Received request to watch statistic on `%s:%s'\n", service, | 627 | "Received request to watch statistic on `%s:%s'\n", service, |
577 | name); | 628 | name); |
578 | #endif | ||
579 | pos = start; | 629 | pos = start; |
580 | while (pos != NULL) | 630 | while (pos != NULL) |
581 | { | 631 | { |
@@ -613,27 +663,18 @@ handle_watch (void *cls, struct GNUNET_SERVER_Client *client, | |||
613 | 663 | ||
614 | 664 | ||
615 | /** | 665 | /** |
616 | * Task run during shutdown. | 666 | * Actually perform the shutdown. |
617 | * | ||
618 | * @param cls unused | ||
619 | * @param tc unused | ||
620 | */ | 667 | */ |
621 | static void | 668 | static void |
622 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 669 | do_shutdown () |
623 | { | 670 | { |
624 | struct ClientEntry *ce; | ||
625 | struct WatchEntry *we; | 671 | struct WatchEntry *we; |
626 | struct StatsEntry *se; | 672 | struct StatsEntry *se; |
627 | 673 | ||
628 | save (); | 674 | save (); |
629 | GNUNET_SERVER_notification_context_destroy (nc); | 675 | GNUNET_SERVER_notification_context_destroy (nc); |
630 | nc = NULL; | 676 | nc = NULL; |
631 | while (NULL != (ce = client_head)) | 677 | GNUNET_assert (NULL == client_head); |
632 | { | ||
633 | GNUNET_SERVER_client_drop (ce->client); | ||
634 | GNUNET_CONTAINER_DLL_remove (client_head, client_tail, ce); | ||
635 | GNUNET_free (ce); | ||
636 | } | ||
637 | while (NULL != (se = start)) | 678 | while (NULL != (se = start)) |
638 | { | 679 | { |
639 | start = se->next; | 680 | start = se->next; |
@@ -645,6 +686,23 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
645 | } | 686 | } |
646 | GNUNET_free (se); | 687 | GNUNET_free (se); |
647 | } | 688 | } |
689 | GNUNET_SERVER_destroy (srv); | ||
690 | } | ||
691 | |||
692 | |||
693 | /** | ||
694 | * Task run during shutdown. | ||
695 | * | ||
696 | * @param cls unused | ||
697 | * @param tc unused | ||
698 | */ | ||
699 | static void | ||
700 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
701 | { | ||
702 | in_shutdown = GNUNET_YES; | ||
703 | if (NULL != client_head) | ||
704 | return; | ||
705 | do_shutdown (); | ||
648 | } | 706 | } |
649 | 707 | ||
650 | 708 | ||
@@ -689,6 +747,9 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
689 | } | 747 | } |
690 | se = se->next; | 748 | se = se->next; |
691 | } | 749 | } |
750 | if ( (NULL == client_head) && | ||
751 | (GNUNET_YES == in_shutdown) ) | ||
752 | do_shutdown (); | ||
692 | } | 753 | } |
693 | 754 | ||
694 | 755 | ||
@@ -710,7 +771,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
710 | {NULL, NULL, 0, 0} | 771 | {NULL, NULL, 0, 0} |
711 | }; | 772 | }; |
712 | cfg = c; | 773 | cfg = c; |
774 | srv = server; | ||
713 | GNUNET_SERVER_add_handlers (server, handlers); | 775 | GNUNET_SERVER_add_handlers (server, handlers); |
776 | GNUNET_SERVER_ignore_shutdown (server, GNUNET_YES); | ||
714 | nc = GNUNET_SERVER_notification_context_create (server, 16); | 777 | nc = GNUNET_SERVER_notification_context_create (server, 16); |
715 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); | 778 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); |
716 | load (server); | 779 | load (server); |
diff --git a/src/statistics/statistics.h b/src/statistics/statistics.h index 3fcac275a..d5f662cf5 100644 --- a/src/statistics/statistics.h +++ b/src/statistics/statistics.h | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | #include "gnunet_common.h" | 28 | #include "gnunet_common.h" |
29 | 29 | ||
30 | #define DEBUG_STATISTICS GNUNET_EXTRA_LOGGING | ||
31 | 30 | ||
32 | GNUNET_NETWORK_STRUCT_BEGIN | 31 | GNUNET_NETWORK_STRUCT_BEGIN |
33 | 32 | ||
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 2838b7060..100121f2f 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c | |||
@@ -385,10 +385,8 @@ try_connect (struct GNUNET_STATISTICS_Handle *h) | |||
385 | schedule_watch_request (h, h->watches[i]); | 385 | schedule_watch_request (h, h->watches[i]); |
386 | return GNUNET_YES; | 386 | return GNUNET_YES; |
387 | } | 387 | } |
388 | #if DEBUG_STATISTICS | ||
389 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 388 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
390 | _("Failed to connect to statistics service!\n")); | 389 | "Failed to connect to statistics service!\n"); |
391 | #endif | ||
392 | return GNUNET_NO; | 390 | return GNUNET_NO; |
393 | } | 391 | } |
394 | 392 | ||
@@ -444,9 +442,7 @@ process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h, | |||
444 | 442 | ||
445 | if (h->current->aborted) | 443 | if (h->current->aborted) |
446 | { | 444 | { |
447 | #if DEBUG_STATISTICS | ||
448 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration was aborted, ignoring VALUE\n"); | 445 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration was aborted, ignoring VALUE\n"); |
449 | #endif | ||
450 | return GNUNET_OK; /* don't bother */ | 446 | return GNUNET_OK; /* don't bother */ |
451 | } | 447 | } |
452 | size = ntohs (msg->size); | 448 | size = ntohs (msg->size); |
@@ -464,25 +460,19 @@ process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h, | |||
464 | GNUNET_break (0); | 460 | GNUNET_break (0); |
465 | return GNUNET_SYSERR; | 461 | return GNUNET_SYSERR; |
466 | } | 462 | } |
467 | #if DEBUG_STATISTICS | ||
468 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received valid statistic on `%s:%s': %llu\n", | 463 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received valid statistic on `%s:%s': %llu\n", |
469 | service, name, GNUNET_ntohll (smsg->value)); | 464 | service, name, GNUNET_ntohll (smsg->value)); |
470 | #endif | ||
471 | if (GNUNET_OK != | 465 | if (GNUNET_OK != |
472 | h->current->proc (h->current->cls, service, name, | 466 | h->current->proc (h->current->cls, service, name, |
473 | GNUNET_ntohll (smsg->value), | 467 | GNUNET_ntohll (smsg->value), |
474 | 0 != | 468 | 0 != |
475 | (ntohl (smsg->uid) & GNUNET_STATISTICS_PERSIST_BIT))) | 469 | (ntohl (smsg->uid) & GNUNET_STATISTICS_PERSIST_BIT))) |
476 | { | 470 | { |
477 | #if DEBUG_STATISTICS | ||
478 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 471 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
479 | "Processing of remaining statistics aborted by client.\n"); | 472 | "Processing of remaining statistics aborted by client.\n"); |
480 | #endif | ||
481 | h->current->aborted = GNUNET_YES; | 473 | h->current->aborted = GNUNET_YES; |
482 | } | 474 | } |
483 | #if DEBUG_STATISTICS | ||
484 | LOG (GNUNET_ERROR_TYPE_DEBUG, "VALUE processed successfully\n"); | 475 | LOG (GNUNET_ERROR_TYPE_DEBUG, "VALUE processed successfully\n"); |
485 | #endif | ||
486 | return GNUNET_OK; | 476 | return GNUNET_OK; |
487 | } | 477 | } |
488 | 478 | ||
@@ -541,10 +531,8 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg) | |||
541 | 531 | ||
542 | if (msg == NULL) | 532 | if (msg == NULL) |
543 | { | 533 | { |
544 | #if DEBUG_STATISTICS | ||
545 | LOG (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 534 | LOG (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
546 | "Error receiving statistics from service, is the service running?\n"); | 535 | "Error receiving statistics from service, is the service running?\n"); |
547 | #endif | ||
548 | do_disconnect (h); | 536 | do_disconnect (h); |
549 | reconnect_later (h); | 537 | reconnect_later (h); |
550 | return; | 538 | return; |
@@ -552,9 +540,7 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg) | |||
552 | switch (ntohs (msg->type)) | 540 | switch (ntohs (msg->type)) |
553 | { | 541 | { |
554 | case GNUNET_MESSAGE_TYPE_STATISTICS_END: | 542 | case GNUNET_MESSAGE_TYPE_STATISTICS_END: |
555 | #if DEBUG_STATISTICS | ||
556 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received end of statistics marker\n"); | 543 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received end of statistics marker\n"); |
557 | #endif | ||
558 | if (NULL == (c = h->current)) | 544 | if (NULL == (c = h->current)) |
559 | { | 545 | { |
560 | GNUNET_break (0); | 546 | GNUNET_break (0); |
@@ -586,10 +572,8 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg) | |||
586 | return; | 572 | return; |
587 | } | 573 | } |
588 | /* finally, look for more! */ | 574 | /* finally, look for more! */ |
589 | #if DEBUG_STATISTICS | ||
590 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 575 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
591 | "Processing VALUE done, now reading more\n"); | 576 | "Processing VALUE done, now reading more\n"); |
592 | #endif | ||
593 | GNUNET_CLIENT_receive (h->client, &receive_stats, h, | 577 | GNUNET_CLIENT_receive (h->client, &receive_stats, h, |
594 | GNUNET_TIME_absolute_get_remaining (h-> | 578 | GNUNET_TIME_absolute_get_remaining (h-> |
595 | current->timeout)); | 579 | current->timeout)); |
@@ -641,10 +625,8 @@ transmit_get (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | |||
641 | if (buf == NULL) | 625 | if (buf == NULL) |
642 | { | 626 | { |
643 | /* timeout / error */ | 627 | /* timeout / error */ |
644 | #if DEBUG_STATISTICS | ||
645 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 628 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
646 | "Transmission of request for statistics failed!\n"); | 629 | "Transmission of request for statistics failed!\n"); |
647 | #endif | ||
648 | do_disconnect (handle); | 630 | do_disconnect (handle); |
649 | reconnect_later (handle); | 631 | reconnect_later (handle); |
650 | return 0; | 632 | return 0; |
@@ -662,10 +644,8 @@ transmit_get (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | |||
662 | c->name)); | 644 | c->name)); |
663 | if (GNUNET_YES != handle->receiving) | 645 | if (GNUNET_YES != handle->receiving) |
664 | { | 646 | { |
665 | #if DEBUG_STATISTICS | ||
666 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 647 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
667 | "Transmission of GET done, now reading response\n"); | 648 | "Transmission of GET done, now reading response\n"); |
668 | #endif | ||
669 | handle->receiving = GNUNET_YES; | 649 | handle->receiving = GNUNET_YES; |
670 | GNUNET_CLIENT_receive (handle->client, &receive_stats, handle, | 650 | GNUNET_CLIENT_receive (handle->client, &receive_stats, handle, |
671 | GNUNET_TIME_absolute_get_remaining (c->timeout)); | 651 | GNUNET_TIME_absolute_get_remaining (c->timeout)); |
@@ -694,18 +674,14 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | |||
694 | if (buf == NULL) | 674 | if (buf == NULL) |
695 | { | 675 | { |
696 | /* timeout / error */ | 676 | /* timeout / error */ |
697 | #if DEBUG_STATISTICS | ||
698 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 677 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
699 | "Transmission of request for statistics failed!\n"); | 678 | "Transmission of request for statistics failed!\n"); |
700 | #endif | ||
701 | do_disconnect (handle); | 679 | do_disconnect (handle); |
702 | reconnect_later (handle); | 680 | reconnect_later (handle); |
703 | return 0; | 681 | return 0; |
704 | } | 682 | } |
705 | #if DEBUG_STATISTICS | ||
706 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting watch request for `%s'\n", | 683 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting watch request for `%s'\n", |
707 | handle->current->name); | 684 | handle->current->name); |
708 | #endif | ||
709 | slen1 = strlen (handle->current->subsystem) + 1; | 685 | slen1 = strlen (handle->current->subsystem) + 1; |
710 | slen2 = strlen (handle->current->name) + 1; | 686 | slen2 = strlen (handle->current->name) + 1; |
711 | msize = slen1 + slen2 + sizeof (struct GNUNET_MessageHeader); | 687 | msize = slen1 + slen2 + sizeof (struct GNUNET_MessageHeader); |
@@ -977,10 +953,8 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) | |||
977 | timeout, GNUNET_YES, | 953 | timeout, GNUNET_YES, |
978 | &transmit_action, h))) | 954 | &transmit_action, h))) |
979 | { | 955 | { |
980 | #if DEBUG_STATISTICS | ||
981 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 956 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
982 | "Failed to transmit request to statistics service.\n"); | 957 | "Failed to transmit request to statistics service.\n"); |
983 | #endif | ||
984 | do_disconnect (h); | 958 | do_disconnect (h); |
985 | reconnect_later (h); | 959 | reconnect_later (h); |
986 | } | 960 | } |