diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-23 20:38:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-23 20:38:18 +0000 |
commit | 996d1af584e8ea60a3e833d4e145bc866a3cba45 (patch) | |
tree | f664853632f37b6acb35b82bfb49eb825ed2ae59 /src/statistics | |
parent | aae8cc8afe0bb827dc1b6601b2e5e3a14b25c2ca (diff) | |
download | gnunet-996d1af584e8ea60a3e833d4e145bc866a3cba45.tar.gz gnunet-996d1af584e8ea60a3e833d4e145bc866a3cba45.zip |
-doxgen, use modern client API
Diffstat (limited to 'src/statistics')
-rw-r--r-- | src/statistics/gnunet-service-statistics.c | 163 | ||||
-rw-r--r-- | src/statistics/gnunet-statistics.c | 41 |
2 files changed, 108 insertions, 96 deletions
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 6c3d173c4..4d8251cf4 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c | |||
@@ -68,7 +68,7 @@ struct WatchEntry | |||
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Is last_value valid | 70 | * Is last_value valid |
71 | * GNUNET_NO : last_value is n/a, GNUNET_YES: last_value is valid | 71 | * #GNUNET_NO : last_value is n/a, #GNUNET_YES: last_value is valid |
72 | */ | 72 | */ |
73 | int last_value_set; | 73 | int last_value_set; |
74 | 74 | ||
@@ -81,16 +81,6 @@ struct WatchEntry | |||
81 | struct ClientEntry | 81 | struct ClientEntry |
82 | { | 82 | { |
83 | /** | 83 | /** |
84 | * Clients are kept in a linked list. | ||
85 | */ | ||
86 | struct ClientEntry *next; | ||
87 | |||
88 | /** | ||
89 | * Clients are kept in a linked list. | ||
90 | */ | ||
91 | struct ClientEntry *prev; | ||
92 | |||
93 | /** | ||
94 | * Corresponding server handle. | 84 | * Corresponding server handle. |
95 | */ | 85 | */ |
96 | struct GNUNET_SERVER_Client *client; | 86 | struct GNUNET_SERVER_Client *client; |
@@ -113,14 +103,12 @@ struct StatsEntry | |||
113 | struct StatsEntry *next; | 103 | struct StatsEntry *next; |
114 | 104 | ||
115 | /** | 105 | /** |
116 | * Name of the service, points into the | 106 | * Name of the service, points into the middle of @e msg. |
117 | * middle of msg. | ||
118 | */ | 107 | */ |
119 | const char *service; | 108 | const char *service; |
120 | 109 | ||
121 | /** | 110 | /** |
122 | * Name for the value, points into | 111 | * Name for the value, points into the middle of @e msg. |
123 | * the middle of msg. | ||
124 | */ | 112 | */ |
125 | const char *name; | 113 | const char *name; |
126 | 114 | ||
@@ -132,14 +120,12 @@ struct StatsEntry | |||
132 | struct GNUNET_STATISTICS_SetMessage *msg; | 120 | struct GNUNET_STATISTICS_SetMessage *msg; |
133 | 121 | ||
134 | /** | 122 | /** |
135 | * Watch context for changes to this | 123 | * Watch context for changes to this value, or NULL for none. |
136 | * value, or NULL for none. | ||
137 | */ | 124 | */ |
138 | struct WatchEntry *we_head; | 125 | struct WatchEntry *we_head; |
139 | 126 | ||
140 | /** | 127 | /** |
141 | * Watch context for changes to this | 128 | * Watch context for changes to this value, or NULL for none. |
142 | * value, or NULL for none. | ||
143 | */ | 129 | */ |
144 | struct WatchEntry *we_tail; | 130 | struct WatchEntry *we_tail; |
145 | 131 | ||
@@ -160,7 +146,7 @@ struct StatsEntry | |||
160 | 146 | ||
161 | /** | 147 | /** |
162 | * Is this value set? | 148 | * Is this value set? |
163 | * GNUNET_NO : value is n/a, GNUNET_YES: value is valid | 149 | * #GNUNET_NO : value is n/a, #GNUNET_YES: value is valid |
164 | */ | 150 | */ |
165 | int set; | 151 | int set; |
166 | 152 | ||
@@ -177,14 +163,9 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
177 | static struct StatsEntry *start; | 163 | static struct StatsEntry *start; |
178 | 164 | ||
179 | /** | 165 | /** |
180 | * Head of linked list of connected clients. | 166 | * Number of connected clients. |
181 | */ | 167 | */ |
182 | static struct ClientEntry *client_head; | 168 | static unsigned int client_count; |
183 | |||
184 | /** | ||
185 | * Tail of linked list of connected clients. | ||
186 | */ | ||
187 | static struct ClientEntry *client_tail; | ||
188 | 169 | ||
189 | /** | 170 | /** |
190 | * Handle to our server. | 171 | * Handle to our server. |
@@ -202,7 +183,7 @@ static struct GNUNET_SERVER_NotificationContext *nc; | |||
202 | static uint32_t uidgen; | 183 | static uint32_t uidgen; |
203 | 184 | ||
204 | /** | 185 | /** |
205 | * Set to YES if we are shutting down as soon as possible. | 186 | * Set to #GNUNET_YES if we are shutting down as soon as possible. |
206 | */ | 187 | */ |
207 | static int in_shutdown; | 188 | static int in_shutdown; |
208 | 189 | ||
@@ -210,12 +191,13 @@ static int in_shutdown; | |||
210 | /** | 191 | /** |
211 | * Inject a message to our server with a client of 'NULL'. | 192 | * Inject a message to our server with a client of 'NULL'. |
212 | * | 193 | * |
213 | * @param cls the 'struct GNUNET_SERVER_Handle' | 194 | * @param cls the `struct GNUNET_SERVER_Handle` |
214 | * @param client unused | 195 | * @param client unused |
215 | * @param msg message to inject | 196 | * @param msg message to inject |
216 | */ | 197 | */ |
217 | static int | 198 | static int |
218 | inject_message (void *cls, void *client, const struct GNUNET_MessageHeader *msg) | 199 | inject_message (void *cls, void *client, |
200 | const struct GNUNET_MessageHeader *msg) | ||
219 | { | 201 | { |
220 | struct GNUNET_SERVER_Handle *server = cls; | 202 | struct GNUNET_SERVER_Handle *server = cls; |
221 | 203 | ||
@@ -225,9 +207,8 @@ inject_message (void *cls, void *client, const struct GNUNET_MessageHeader *msg) | |||
225 | 207 | ||
226 | 208 | ||
227 | /** | 209 | /** |
228 | * Load persistent values from disk. Disk format is | 210 | * Load persistent values from disk. Disk format is exactly the same |
229 | * exactly the same format that we also use for | 211 | * format that we also use for setting the values over the network. |
230 | * setting the values over the network. | ||
231 | * | 212 | * |
232 | * @param server handle to the server context | 213 | * @param server handle to the server context |
233 | */ | 214 | */ |
@@ -356,7 +337,8 @@ save () | |||
356 | * @param e value to transmit | 337 | * @param e value to transmit |
357 | */ | 338 | */ |
358 | static void | 339 | static void |
359 | transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e) | 340 | transmit (struct GNUNET_SERVER_Client *client, |
341 | const struct StatsEntry *e) | ||
360 | { | 342 | { |
361 | struct GNUNET_STATISTICS_ReplyMessage *m; | 343 | struct GNUNET_STATISTICS_ReplyMessage *m; |
362 | size_t size; | 344 | size_t size; |
@@ -377,8 +359,11 @@ transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e) | |||
377 | GNUNET_STRINGS_buffer_fill ((char *) &m[1], size, 2, | 359 | GNUNET_STRINGS_buffer_fill ((char *) &m[1], size, 2, |
378 | e->service, e->name)); | 360 | e->service, e->name)); |
379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 361 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
380 | "Transmitting value for `%s:%s' (%d): %llu\n", e->service, | 362 | "Transmitting value for `%s:%s' (%d): %llu\n", |
381 | e->name, e->persistent, e->value); | 363 | e->service, |
364 | e->name, | ||
365 | e->persistent, | ||
366 | e->value); | ||
382 | GNUNET_SERVER_notification_context_unicast (nc, client, &m->header, | 367 | GNUNET_SERVER_notification_context_unicast (nc, client, &m->header, |
383 | GNUNET_NO); | 368 | GNUNET_NO); |
384 | GNUNET_free (m); | 369 | GNUNET_free (m); |
@@ -394,7 +379,9 @@ transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e) | |||
394 | * @return 1 if they match, 0 if not | 379 | * @return 1 if they match, 0 if not |
395 | */ | 380 | */ |
396 | static int | 381 | static int |
397 | matches (const struct StatsEntry *e, const char *service, const char *name) | 382 | matches (const struct StatsEntry *e, |
383 | const char *service, | ||
384 | const char *name) | ||
398 | { | 385 | { |
399 | return ((0 == strlen (service)) || (0 == strcmp (service, e->service))) && | 386 | return ((0 == strlen (service)) || (0 == strcmp (service, e->service))) && |
400 | ((0 == strlen (name)) || (0 == strcmp (name, e->name))); | 387 | ((0 == strlen (name)) || (0 == strcmp (name, e->name))); |
@@ -412,14 +399,11 @@ make_client_entry (struct GNUNET_SERVER_Client *client) | |||
412 | { | 399 | { |
413 | struct ClientEntry *ce; | 400 | struct ClientEntry *ce; |
414 | 401 | ||
415 | GNUNET_assert (client != NULL); | 402 | GNUNET_assert (NULL != client); |
416 | ce = client_head; | 403 | ce = GNUNET_SERVER_client_get_user_context (client, |
417 | while (ce != NULL) | 404 | struct ClientEntry); |
418 | { | 405 | if (NULL != ce) |
419 | if (ce->client == client) | 406 | return ce; |
420 | return ce; | ||
421 | ce = ce->next; | ||
422 | } | ||
423 | if (NULL == nc) | 407 | if (NULL == nc) |
424 | { | 408 | { |
425 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 409 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -427,7 +411,8 @@ make_client_entry (struct GNUNET_SERVER_Client *client) | |||
427 | } | 411 | } |
428 | ce = GNUNET_new (struct ClientEntry); | 412 | ce = GNUNET_new (struct ClientEntry); |
429 | ce->client = client; | 413 | ce->client = client; |
430 | GNUNET_CONTAINER_DLL_insert (client_head, client_tail, ce); | 414 | GNUNET_SERVER_client_set_user_context (client, ce); |
415 | client_count++; | ||
431 | GNUNET_SERVER_notification_context_add (nc, client); | 416 | GNUNET_SERVER_notification_context_add (nc, client); |
432 | return ce; | 417 | return ce; |
433 | } | 418 | } |
@@ -439,11 +424,12 @@ make_client_entry (struct GNUNET_SERVER_Client *client) | |||
439 | * @param cls closure | 424 | * @param cls closure |
440 | * @param client identification of the client | 425 | * @param client identification of the client |
441 | * @param message the actual message | 426 | * @param message the actual message |
442 | * @return GNUNET_OK to keep the connection open, | 427 | * @return #GNUNET_OK to keep the connection open, |
443 | * GNUNET_SYSERR to close it (signal serious error) | 428 | * #GNUNET_SYSERR to close it (signal serious error) |
444 | */ | 429 | */ |
445 | static void | 430 | static void |
446 | handle_get (void *cls, struct GNUNET_SERVER_Client *client, | 431 | handle_get (void *cls, |
432 | struct GNUNET_SERVER_Client *client, | ||
447 | const struct GNUNET_MessageHeader *message) | 433 | const struct GNUNET_MessageHeader *message) |
448 | { | 434 | { |
449 | struct GNUNET_MessageHeader end; | 435 | struct GNUNET_MessageHeader end; |
@@ -466,7 +452,8 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client, | |||
466 | } | 452 | } |
467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 453 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
468 | "Received request for statistics on `%s:%s'\n", | 454 | "Received request for statistics on `%s:%s'\n", |
469 | strlen (service) ? service : "*", strlen (name) ? name : "*"); | 455 | strlen (service) ? service : "*", |
456 | strlen (name) ? name : "*"); | ||
470 | for (pos = start; NULL != pos; pos = pos->next) | 457 | for (pos = start; NULL != pos; pos = pos->next) |
471 | if (matches (pos, service, name)) | 458 | if (matches (pos, service, name)) |
472 | transmit (client, pos); | 459 | transmit (client, pos); |
@@ -521,7 +508,8 @@ notify_change (struct StatsEntry *se) | |||
521 | * @param message the actual message | 508 | * @param message the actual message |
522 | */ | 509 | */ |
523 | static void | 510 | static void |
524 | handle_set (void *cls, struct GNUNET_SERVER_Client *client, | 511 | handle_set (void *cls, |
512 | struct GNUNET_SERVER_Client *client, | ||
525 | const struct GNUNET_MessageHeader *message) | 513 | const struct GNUNET_MessageHeader *message) |
526 | { | 514 | { |
527 | char *service; | 515 | char *service; |
@@ -637,8 +625,10 @@ handle_set (void *cls, struct GNUNET_SERVER_Client *client, | |||
637 | 625 | ||
638 | start = pos; | 626 | start = pos; |
639 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
640 | "New statistic on `%s:%s' with value %llu created.\n", service, | 628 | "New statistic on `%s:%s' with value %llu created.\n", |
641 | name, pos->value); | 629 | service, |
630 | name, | ||
631 | pos->value); | ||
642 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 632 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
643 | } | 633 | } |
644 | 634 | ||
@@ -651,7 +641,8 @@ handle_set (void *cls, struct GNUNET_SERVER_Client *client, | |||
651 | * @param message the actual message | 641 | * @param message the actual message |
652 | */ | 642 | */ |
653 | static void | 643 | static void |
654 | handle_watch (void *cls, struct GNUNET_SERVER_Client *client, | 644 | handle_watch (void *cls, |
645 | struct GNUNET_SERVER_Client *client, | ||
655 | const struct GNUNET_MessageHeader *message) | 646 | const struct GNUNET_MessageHeader *message) |
656 | { | 647 | { |
657 | char *service; | 648 | char *service; |
@@ -687,15 +678,12 @@ handle_watch (void *cls, struct GNUNET_SERVER_Client *client, | |||
687 | return; | 678 | return; |
688 | } | 679 | } |
689 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 680 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
690 | "Received request to watch statistic on `%s:%s'\n", service, | 681 | "Received request to watch statistic on `%s:%s'\n", |
682 | service, | ||
691 | name); | 683 | name); |
692 | pos = start; | 684 | for (pos = start; NULL != pos; pos = pos->next) |
693 | while (pos != NULL) | ||
694 | { | ||
695 | if (matches (pos, service, name)) | 685 | if (matches (pos, service, name)) |
696 | break; | 686 | break; |
697 | pos = pos->next; | ||
698 | } | ||
699 | if (pos == NULL) | 687 | if (pos == NULL) |
700 | { | 688 | { |
701 | pos = | 689 | pos = |
@@ -715,14 +703,18 @@ handle_watch (void *cls, struct GNUNET_SERVER_Client *client, | |||
715 | memcpy ((void *) pos->name, name, strlen (name) + 1); | 703 | memcpy ((void *) pos->name, name, strlen (name) + 1); |
716 | start = pos; | 704 | start = pos; |
717 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 705 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
718 | "New statistic on `%s:%s' with value %llu created.\n", service, | 706 | "New statistic on `%s:%s' with value %llu created.\n", |
719 | name, pos->value); | 707 | service, |
708 | name, | ||
709 | pos->value); | ||
720 | } | 710 | } |
721 | we = GNUNET_new (struct WatchEntry); | 711 | we = GNUNET_new (struct WatchEntry); |
722 | we->client = client; | 712 | we->client = client; |
723 | we->last_value_set = GNUNET_NO; | 713 | we->last_value_set = GNUNET_NO; |
724 | we->wid = ce->max_wid++; | 714 | we->wid = ce->max_wid++; |
725 | GNUNET_CONTAINER_DLL_insert (pos->we_head, pos->we_tail, we); | 715 | GNUNET_CONTAINER_DLL_insert (pos->we_head, |
716 | pos->we_tail, | ||
717 | we); | ||
726 | if (pos->value != 0) | 718 | if (pos->value != 0) |
727 | notify_change (pos); | 719 | notify_change (pos); |
728 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 720 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -743,13 +735,15 @@ do_shutdown () | |||
743 | save (); | 735 | save (); |
744 | GNUNET_SERVER_notification_context_destroy (nc); | 736 | GNUNET_SERVER_notification_context_destroy (nc); |
745 | nc = NULL; | 737 | nc = NULL; |
746 | GNUNET_assert (NULL == client_head); | 738 | GNUNET_assert (0 == client_count); |
747 | while (NULL != (se = start)) | 739 | while (NULL != (se = start)) |
748 | { | 740 | { |
749 | start = se->next; | 741 | start = se->next; |
750 | while (NULL != (we = se->we_head)) | 742 | while (NULL != (we = se->we_head)) |
751 | { | 743 | { |
752 | GNUNET_CONTAINER_DLL_remove (se->we_head, se->we_tail, we); | 744 | GNUNET_CONTAINER_DLL_remove (se->we_head, |
745 | se->we_tail, | ||
746 | we); | ||
753 | GNUNET_free (we); | 747 | GNUNET_free (we); |
754 | } | 748 | } |
755 | GNUNET_free (se); | 749 | GNUNET_free (se); |
@@ -764,10 +758,11 @@ do_shutdown () | |||
764 | * @param tc unused | 758 | * @param tc unused |
765 | */ | 759 | */ |
766 | static void | 760 | static void |
767 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 761 | shutdown_task (void *cls, |
762 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
768 | { | 763 | { |
769 | in_shutdown = GNUNET_YES; | 764 | in_shutdown = GNUNET_YES; |
770 | if (NULL != client_head) | 765 | if (0 != client_count) |
771 | return; | 766 | return; |
772 | do_shutdown (); | 767 | do_shutdown (); |
773 | } | 768 | } |
@@ -780,24 +775,23 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
780 | * @param client identification of the client | 775 | * @param client identification of the client |
781 | */ | 776 | */ |
782 | static void | 777 | static void |
783 | handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | 778 | handle_client_disconnect (void *cls, |
779 | struct GNUNET_SERVER_Client *client) | ||
784 | { | 780 | { |
785 | struct ClientEntry *ce; | 781 | struct ClientEntry *ce; |
786 | struct WatchEntry *we; | 782 | struct WatchEntry *we; |
787 | struct WatchEntry *wen; | 783 | struct WatchEntry *wen; |
788 | struct StatsEntry *se; | 784 | struct StatsEntry *se; |
789 | 785 | ||
790 | ce = client_head; | 786 | if (NULL == client) |
791 | while (NULL != ce) | 787 | return; |
792 | { | 788 | ce = GNUNET_SERVER_client_get_user_context (client, |
793 | if (ce->client == client) | 789 | struct ClientEntry); |
794 | { | 790 | if (NULL == ce) |
795 | GNUNET_CONTAINER_DLL_remove (client_head, client_tail, ce); | 791 | return; |
796 | GNUNET_free (ce); | 792 | GNUNET_SERVER_client_set_user_context (client, |
797 | break; | 793 | NULL); |
798 | } | 794 | client_count--; |
799 | ce = ce->next; | ||
800 | } | ||
801 | se = start; | 795 | se = start; |
802 | while (NULL != se) | 796 | while (NULL != se) |
803 | { | 797 | { |
@@ -812,7 +806,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
812 | } | 806 | } |
813 | se = se->next; | 807 | se = se->next; |
814 | } | 808 | } |
815 | if ( (NULL == client_head) && | 809 | if ( (0 == client_count) && |
816 | (GNUNET_YES == in_shutdown) ) | 810 | (GNUNET_YES == in_shutdown) ) |
817 | do_shutdown (); | 811 | do_shutdown (); |
818 | } | 812 | } |
@@ -826,7 +820,8 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
826 | * @param c configuration to use | 820 | * @param c configuration to use |
827 | */ | 821 | */ |
828 | static void | 822 | static void |
829 | run (void *cls, struct GNUNET_SERVER_Handle *server, | 823 | run (void *cls, |
824 | struct GNUNET_SERVER_Handle *server, | ||
830 | const struct GNUNET_CONFIGURATION_Handle *c) | 825 | const struct GNUNET_CONFIGURATION_Handle *c) |
831 | { | 826 | { |
832 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 827 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
@@ -841,7 +836,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
841 | nc = GNUNET_SERVER_notification_context_create (server, 16); | 836 | nc = GNUNET_SERVER_notification_context_create (server, 16); |
842 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); | 837 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); |
843 | load (server); | 838 | load (server); |
844 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 839 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
840 | &shutdown_task, | ||
845 | NULL); | 841 | NULL); |
846 | } | 842 | } |
847 | 843 | ||
@@ -867,7 +863,8 @@ main (int argc, char *const *argv) | |||
867 | /** | 863 | /** |
868 | * MINIMIZE heap size (way below 128k) since this process doesn't need much. | 864 | * MINIMIZE heap size (way below 128k) since this process doesn't need much. |
869 | */ | 865 | */ |
870 | void __attribute__ ((constructor)) GNUNET_ARM_memory_init () | 866 | void __attribute__ ((constructor)) |
867 | GNUNET_STATISTICS_memory_init () | ||
871 | { | 868 | { |
872 | mallopt (M_TRIM_THRESHOLD, 4 * 1024); | 869 | mallopt (M_TRIM_THRESHOLD, 4 * 1024); |
873 | mallopt (M_TOP_PAD, 1 * 1024); | 870 | mallopt (M_TOP_PAD, 1 * 1024); |
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index 857c9bde6..4adcaa888 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c | |||
@@ -93,7 +93,10 @@ static int set_value; | |||
93 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration | 93 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration |
94 | */ | 94 | */ |
95 | static int | 95 | static int |
96 | printer (void *cls, const char *subsystem, const char *name, uint64_t value, | 96 | printer (void *cls, |
97 | const char *subsystem, | ||
98 | const char *name, | ||
99 | uint64_t value, | ||
97 | int is_persistent) | 100 | int is_persistent) |
98 | { | 101 | { |
99 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); | 102 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); |
@@ -137,10 +140,14 @@ cleanup (void *cls, int success) | |||
137 | if (success != GNUNET_OK) | 140 | if (success != GNUNET_OK) |
138 | { | 141 | { |
139 | if (NULL == remote_host) | 142 | if (NULL == remote_host) |
140 | FPRINTF (stderr, "%s", _("Failed to obtain statistics.\n")); | 143 | FPRINTF (stderr, |
144 | "%s", | ||
145 | _("Failed to obtain statistics.\n")); | ||
141 | else | 146 | else |
142 | FPRINTF (stderr, _("Failed to obtain statistics from host `%s:%llu'\n"), | 147 | FPRINTF (stderr, |
143 | remote_host, remote_port); | 148 | _("Failed to obtain statistics from host `%s:%llu'\n"), |
149 | remote_host, | ||
150 | remote_port); | ||
144 | ret = 1; | 151 | ret = 1; |
145 | } | 152 | } |
146 | GNUNET_SCHEDULER_shutdown (); | 153 | GNUNET_SCHEDULER_shutdown (); |
@@ -154,7 +161,8 @@ cleanup (void *cls, int success) | |||
154 | * @param tc scheduler context | 161 | * @param tc scheduler context |
155 | */ | 162 | */ |
156 | static void | 163 | static void |
157 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 164 | shutdown_task (void *cls, |
165 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
158 | { | 166 | { |
159 | struct GNUNET_STATISTICS_Handle *h = cls; | 167 | struct GNUNET_STATISTICS_Handle *h = cls; |
160 | 168 | ||
@@ -177,20 +185,21 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
177 | * @param tc schedueler context | 185 | * @param tc schedueler context |
178 | */ | 186 | */ |
179 | static void | 187 | static void |
180 | main_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 188 | main_task (void *cls, |
189 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
181 | { | 190 | { |
182 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 191 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
183 | struct GNUNET_STATISTICS_Handle *h; | 192 | struct GNUNET_STATISTICS_Handle *h; |
184 | 193 | ||
185 | if (set_value) | 194 | if (set_value) |
186 | { | 195 | { |
187 | if (subsystem == NULL) | 196 | if (NULL == subsystem) |
188 | { | 197 | { |
189 | FPRINTF (stderr, "%s", _("Missing argument: subsystem \n")); | 198 | FPRINTF (stderr, "%s", _("Missing argument: subsystem \n")); |
190 | ret = 1; | 199 | ret = 1; |
191 | return; | 200 | return; |
192 | } | 201 | } |
193 | if (name == NULL) | 202 | if (NULL == name) |
194 | { | 203 | { |
195 | FPRINTF (stderr, "%s", _("Missing argument: name\n")); | 204 | FPRINTF (stderr, "%s", _("Missing argument: name\n")); |
196 | ret = 1; | 205 | ret = 1; |
@@ -238,7 +247,6 @@ main_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
238 | } | 247 | } |
239 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 248 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
240 | &shutdown_task, h); | 249 | &shutdown_task, h); |
241 | |||
242 | } | 250 | } |
243 | 251 | ||
244 | 252 | ||
@@ -258,22 +266,29 @@ resolver_test_task (void *cls, | |||
258 | if (GNUNET_YES != result) | 266 | if (GNUNET_YES != result) |
259 | { | 267 | { |
260 | FPRINTF (stderr, | 268 | FPRINTF (stderr, |
261 | _("Trying to connect to remote host, but service `%s' is not running\n"), "resolver"); | 269 | _("Trying to connect to remote host, but service `%s' is not running\n"), |
270 | "resolver"); | ||
262 | return; | 271 | return; |
263 | } | 272 | } |
264 | /* connect to a remote host */ | 273 | /* connect to a remote host */ |
265 | if (0 == remote_port) | 274 | if (0 == remote_port) |
266 | { | 275 | { |
267 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "statistics", "PORT", &remote_port)) | 276 | if (GNUNET_SYSERR == |
277 | GNUNET_CONFIGURATION_get_value_number (cfg, "statistics", | ||
278 | "PORT", | ||
279 | &remote_port)) | ||
268 | { | 280 | { |
269 | FPRINTF (stderr, _("A port is required to connect to host `%s'\n"), remote_host); | 281 | FPRINTF (stderr, |
282 | _("A port is required to connect to host `%s'\n"), | ||
283 | remote_host); | ||
270 | return; | 284 | return; |
271 | } | 285 | } |
272 | } | 286 | } |
273 | else if (65535 <= remote_port) | 287 | else if (65535 <= remote_port) |
274 | { | 288 | { |
275 | FPRINTF (stderr, | 289 | FPRINTF (stderr, |
276 | _("A port has to be between 1 and 65535 to connect to host `%s'\n"), remote_host); | 290 | _("A port has to be between 1 and 65535 to connect to host `%s'\n"), |
291 | remote_host); | ||
277 | return; | 292 | return; |
278 | } | 293 | } |
279 | 294 | ||