diff options
-rw-r--r-- | src/dv/test_transport_dv_data.conf | 4 | ||||
-rw-r--r-- | src/include/gnunet_statistics_service.h | 36 | ||||
-rw-r--r-- | src/include/gnunet_transport_plugin.h | 1 | ||||
-rw-r--r-- | src/statistics/statistics_api.c | 134 |
4 files changed, 112 insertions, 63 deletions
diff --git a/src/dv/test_transport_dv_data.conf b/src/dv/test_transport_dv_data.conf index 37dbc7f16..9d7217176 100644 --- a/src/dv/test_transport_dv_data.conf +++ b/src/dv/test_transport_dv_data.conf | |||
@@ -1,5 +1,9 @@ | |||
1 | @INLINE@ template_dv.conf | 1 | @INLINE@ template_dv.conf |
2 | 2 | ||
3 | [testbed] | ||
4 | SETUP_TIMEOUT = 60 m | ||
5 | OPERATION_TIMEOUT = 30 m | ||
6 | |||
3 | [transport] | 7 | [transport] |
4 | PORT = 2565 | 8 | PORT = 2565 |
5 | PLUGINS = tcp dv | 9 | PLUGINS = tcp dv |
diff --git a/src/include/gnunet_statistics_service.h b/src/include/gnunet_statistics_service.h index 25562580a..41788d67e 100644 --- a/src/include/gnunet_statistics_service.h +++ b/src/include/gnunet_statistics_service.h | |||
@@ -61,10 +61,13 @@ struct GNUNET_STATISTICS_Handle; | |||
61 | * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not | 61 | * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not |
62 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration | 62 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration |
63 | */ | 63 | */ |
64 | typedef int (*GNUNET_STATISTICS_Iterator) (void *cls, const char *subsystem, | 64 | typedef int (*GNUNET_STATISTICS_Iterator) (void *cls, |
65 | const char *name, uint64_t value, | 65 | const char *subsystem, |
66 | const char *name, | ||
67 | uint64_t value, | ||
66 | int is_persistent); | 68 | int is_persistent); |
67 | 69 | ||
70 | |||
68 | /** | 71 | /** |
69 | * Get handle for the statistics service. | 72 | * Get handle for the statistics service. |
70 | * | 73 | * |
@@ -86,7 +89,8 @@ GNUNET_STATISTICS_create (const char *subsystem, | |||
86 | * be completed | 89 | * be completed |
87 | */ | 90 | */ |
88 | void | 91 | void |
89 | GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first); | 92 | GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, |
93 | int sync_first); | ||
90 | 94 | ||
91 | 95 | ||
92 | /** | 96 | /** |
@@ -101,8 +105,10 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first); | |||
101 | */ | 105 | */ |
102 | int | 106 | int |
103 | GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, | 107 | GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, |
104 | const char *subsystem, const char *name, | 108 | const char *subsystem, |
105 | GNUNET_STATISTICS_Iterator proc, void *proc_cls); | 109 | const char *name, |
110 | GNUNET_STATISTICS_Iterator proc, | ||
111 | void *proc_cls); | ||
106 | 112 | ||
107 | 113 | ||
108 | /** | 114 | /** |
@@ -117,8 +123,10 @@ GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, | |||
117 | */ | 123 | */ |
118 | int | 124 | int |
119 | GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle, | 125 | GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle, |
120 | const char *subsystem, const char *name, | 126 | const char *subsystem, |
121 | GNUNET_STATISTICS_Iterator proc, void *proc_cls); | 127 | const char *name, |
128 | GNUNET_STATISTICS_Iterator proc, | ||
129 | void *proc_cls); | ||
122 | 130 | ||
123 | 131 | ||
124 | /** | 132 | /** |
@@ -128,7 +136,8 @@ GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle, | |||
128 | * @param success #GNUNET_OK if statistics were | 136 | * @param success #GNUNET_OK if statistics were |
129 | * successfully obtained, #GNUNET_SYSERR if not. | 137 | * successfully obtained, #GNUNET_SYSERR if not. |
130 | */ | 138 | */ |
131 | typedef void (*GNUNET_STATISTICS_Callback) (void *cls, int success); | 139 | typedef void (*GNUNET_STATISTICS_Callback) (void *cls, |
140 | int success); | ||
132 | 141 | ||
133 | 142 | ||
134 | /** | 143 | /** |
@@ -153,7 +162,8 @@ struct GNUNET_STATISTICS_GetHandle; | |||
153 | */ | 162 | */ |
154 | struct GNUNET_STATISTICS_GetHandle * | 163 | struct GNUNET_STATISTICS_GetHandle * |
155 | GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle, | 164 | GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle, |
156 | const char *subsystem, const char *name, | 165 | const char *subsystem, |
166 | const char *name, | ||
157 | struct GNUNET_TIME_Relative timeout, | 167 | struct GNUNET_TIME_Relative timeout, |
158 | GNUNET_STATISTICS_Callback cont, | 168 | GNUNET_STATISTICS_Callback cont, |
159 | GNUNET_STATISTICS_Iterator proc, void *cls); | 169 | GNUNET_STATISTICS_Iterator proc, void *cls); |
@@ -180,7 +190,9 @@ GNUNET_STATISTICS_get_cancel (struct GNUNET_STATISTICS_GetHandle *gh); | |||
180 | */ | 190 | */ |
181 | void | 191 | void |
182 | GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle, | 192 | GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle, |
183 | const char *name, uint64_t value, int make_persistent); | 193 | const char *name, |
194 | uint64_t value, | ||
195 | int make_persistent); | ||
184 | 196 | ||
185 | 197 | ||
186 | /** | 198 | /** |
@@ -194,7 +206,9 @@ GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle, | |||
194 | */ | 206 | */ |
195 | void | 207 | void |
196 | GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle, | 208 | GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle, |
197 | const char *name, int64_t delta, int make_persistent); | 209 | const char *name, |
210 | int64_t delta, | ||
211 | int make_persistent); | ||
198 | 212 | ||
199 | 213 | ||
200 | 214 | ||
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h index 9df077823..62c8f1638 100644 --- a/src/include/gnunet_transport_plugin.h +++ b/src/include/gnunet_transport_plugin.h | |||
@@ -488,6 +488,7 @@ typedef struct Session * | |||
488 | (*GNUNET_TRANSPORT_CreateSession) (void *cls, | 488 | (*GNUNET_TRANSPORT_CreateSession) (void *cls, |
489 | const struct GNUNET_HELLO_Address *address); | 489 | const struct GNUNET_HELLO_Address *address); |
490 | 490 | ||
491 | |||
491 | /** | 492 | /** |
492 | * Function that will be called whenever the transport service wants to | 493 | * Function that will be called whenever the transport service wants to |
493 | * notify the plugin that a session is still active and in use and | 494 | * notify the plugin that a session is still active and in use and |
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 04e85a07e..f1adcae4c 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c | |||
@@ -326,15 +326,11 @@ static void | |||
326 | schedule_watch_request (struct GNUNET_STATISTICS_Handle *h, | 326 | schedule_watch_request (struct GNUNET_STATISTICS_Handle *h, |
327 | struct GNUNET_STATISTICS_WatchEntry *watch) | 327 | struct GNUNET_STATISTICS_WatchEntry *watch) |
328 | { | 328 | { |
329 | |||
330 | struct GNUNET_STATISTICS_GetHandle *ai; | 329 | struct GNUNET_STATISTICS_GetHandle *ai; |
331 | size_t slen; | 330 | size_t slen; |
332 | size_t nlen; | 331 | size_t nlen; |
333 | size_t nsize; | 332 | size_t nsize; |
334 | 333 | ||
335 | GNUNET_assert (NULL != h); | ||
336 | GNUNET_assert (NULL != watch); | ||
337 | |||
338 | slen = strlen (watch->subsystem) + 1; | 334 | slen = strlen (watch->subsystem) + 1; |
339 | nlen = strlen (watch->name) + 1; | 335 | nlen = strlen (watch->name) + 1; |
340 | nsize = sizeof (struct GNUNET_MessageHeader) + slen + nlen; | 336 | nsize = sizeof (struct GNUNET_MessageHeader) + slen + nlen; |
@@ -452,11 +448,12 @@ try_connect (struct GNUNET_STATISTICS_Handle *h) | |||
452 | /** | 448 | /** |
453 | * We've waited long enough, reconnect now. | 449 | * We've waited long enough, reconnect now. |
454 | * | 450 | * |
455 | * @param cls the 'struct GNUNET_STATISTICS_Handle' to reconnect | 451 | * @param cls the `struct GNUNET_STATISTICS_Handle` to reconnect |
456 | * @param tc scheduler context (unused) | 452 | * @param tc scheduler context (unused) |
457 | */ | 453 | */ |
458 | static void | 454 | static void |
459 | reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 455 | reconnect_task (void *cls, |
456 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
460 | { | 457 | { |
461 | struct GNUNET_STATISTICS_Handle *h = cls; | 458 | struct GNUNET_STATISTICS_Handle *h = cls; |
462 | 459 | ||
@@ -473,7 +470,7 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
473 | */ | 470 | */ |
474 | static void | 471 | static void |
475 | do_destroy (void *cls, | 472 | do_destroy (void *cls, |
476 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 473 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
477 | { | 474 | { |
478 | struct GNUNET_STATISTICS_Handle *h = cls; | 475 | struct GNUNET_STATISTICS_Handle *h = cls; |
479 | 476 | ||
@@ -519,11 +516,11 @@ reconnect_later (struct GNUNET_STATISTICS_Handle *h) | |||
519 | 516 | ||
520 | 517 | ||
521 | /** | 518 | /** |
522 | * Process a 'GNUNET_MESSAGE_TYPE_STATISTICS_VALUE' message. | 519 | * Process a #GNUNET_MESSAGE_TYPE_STATISTICS_VALUE message. |
523 | * | 520 | * |
524 | * @param h statistics handle | 521 | * @param h statistics handle |
525 | * @param msg message received from the service, never NULL | 522 | * @param msg message received from the service, never NULL |
526 | * @return GNUNET_OK if the message was well-formed | 523 | * @return #GNUNET_OK if the message was well-formed |
527 | */ | 524 | */ |
528 | static int | 525 | static int |
529 | process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h, | 526 | process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h, |
@@ -536,7 +533,8 @@ process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h, | |||
536 | 533 | ||
537 | if (h->current->aborted) | 534 | if (h->current->aborted) |
538 | { | 535 | { |
539 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration was aborted, ignoring VALUE\n"); | 536 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
537 | "Iteration was aborted, ignoring VALUE\n"); | ||
540 | return GNUNET_OK; /* don't bother */ | 538 | return GNUNET_OK; /* don't bother */ |
541 | } | 539 | } |
542 | size = ntohs (msg->size); | 540 | size = ntohs (msg->size); |
@@ -554,8 +552,10 @@ process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h, | |||
554 | GNUNET_break (0); | 552 | GNUNET_break (0); |
555 | return GNUNET_SYSERR; | 553 | return GNUNET_SYSERR; |
556 | } | 554 | } |
557 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received valid statistic on `%s:%s': %llu\n", | 555 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
558 | service, name, GNUNET_ntohll (smsg->value)); | 556 | "Received valid statistic on `%s:%s': %llu\n", |
557 | service, name, | ||
558 | GNUNET_ntohll (smsg->value)); | ||
559 | if (GNUNET_OK != | 559 | if (GNUNET_OK != |
560 | h->current->proc (h->current->cls, service, name, | 560 | h->current->proc (h->current->cls, service, name, |
561 | GNUNET_ntohll (smsg->value), | 561 | GNUNET_ntohll (smsg->value), |
@@ -566,7 +566,8 @@ process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h, | |||
566 | "Processing of remaining statistics aborted by client.\n"); | 566 | "Processing of remaining statistics aborted by client.\n"); |
567 | h->current->aborted = GNUNET_YES; | 567 | h->current->aborted = GNUNET_YES; |
568 | } | 568 | } |
569 | LOG (GNUNET_ERROR_TYPE_DEBUG, "VALUE processed successfully\n"); | 569 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
570 | "VALUE processed successfully\n"); | ||
570 | return GNUNET_OK; | 571 | return GNUNET_OK; |
571 | } | 572 | } |
572 | 573 | ||
@@ -576,8 +577,8 @@ process_statistics_value_message (struct GNUNET_STATISTICS_Handle *h, | |||
576 | * | 577 | * |
577 | * @param h statistics handle | 578 | * @param h statistics handle |
578 | * @param msg the watch value message | 579 | * @param msg the watch value message |
579 | * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not, | 580 | * @return #GNUNET_OK if the message was well-formed, #GNUNET_SYSERR if not, |
580 | * GNUNET_NO if this watch has been cancelled | 581 | * #GNUNET_NO if this watch has been cancelled |
581 | */ | 582 | */ |
582 | static int | 583 | static int |
583 | process_watch_value (struct GNUNET_STATISTICS_Handle *h, | 584 | process_watch_value (struct GNUNET_STATISTICS_Handle *h, |
@@ -610,6 +611,12 @@ process_watch_value (struct GNUNET_STATISTICS_Handle *h, | |||
610 | } | 611 | } |
611 | 612 | ||
612 | 613 | ||
614 | /** | ||
615 | * Task used to destroy the statistics handle. | ||
616 | * | ||
617 | * @param cls the `struct GNUNET_STATISTICS_Handle` | ||
618 | * @param tc the scheduler context | ||
619 | */ | ||
613 | static void | 620 | static void |
614 | destroy_task (void *cls, | 621 | destroy_task (void *cls, |
615 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 622 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -627,7 +634,8 @@ destroy_task (void *cls, | |||
627 | * @param msg message received, NULL on timeout or fatal error | 634 | * @param msg message received, NULL on timeout or fatal error |
628 | */ | 635 | */ |
629 | static void | 636 | static void |
630 | receive_stats (void *cls, const struct GNUNET_MessageHeader *msg) | 637 | receive_stats (void *cls, |
638 | const struct GNUNET_MessageHeader *msg) | ||
631 | { | 639 | { |
632 | struct GNUNET_STATISTICS_Handle *h = cls; | 640 | struct GNUNET_STATISTICS_Handle *h = cls; |
633 | struct GNUNET_STATISTICS_GetHandle *c; | 641 | struct GNUNET_STATISTICS_GetHandle *c; |
@@ -657,7 +665,8 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg) | |||
657 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 665 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
658 | break; | 666 | break; |
659 | case GNUNET_MESSAGE_TYPE_STATISTICS_END: | 667 | case GNUNET_MESSAGE_TYPE_STATISTICS_END: |
660 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received end of statistics marker\n"); | 668 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
669 | "Received end of statistics marker\n"); | ||
661 | if (NULL == (c = h->current)) | 670 | if (NULL == (c = h->current)) |
662 | { | 671 | { |
663 | GNUNET_break (0); | 672 | GNUNET_break (0); |
@@ -725,12 +734,14 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg) | |||
725 | * the response). | 734 | * the response). |
726 | * | 735 | * |
727 | * @param handle statistics handle | 736 | * @param handle statistics handle |
728 | * @param size how many bytes can we write to buf | 737 | * @param size how many bytes can we write to @a buf |
729 | * @param buf where to write requests to the service | 738 | * @param buf where to write requests to the service |
730 | * @return number of bytes written to buf | 739 | * @return number of bytes written to @a buf |
731 | */ | 740 | */ |
732 | static size_t | 741 | static size_t |
733 | transmit_get (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | 742 | transmit_get (struct GNUNET_STATISTICS_Handle *handle, |
743 | size_t size, | ||
744 | void *buf) | ||
734 | { | 745 | { |
735 | struct GNUNET_STATISTICS_GetHandle *c; | 746 | struct GNUNET_STATISTICS_GetHandle *c; |
736 | struct GNUNET_MessageHeader *hdr; | 747 | struct GNUNET_MessageHeader *hdr; |
@@ -776,12 +787,14 @@ transmit_get (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | |||
776 | * the response). | 787 | * the response). |
777 | * | 788 | * |
778 | * @param handle statistics handle | 789 | * @param handle statistics handle |
779 | * @param size how many bytes can we write to buf | 790 | * @param size how many bytes can we write to @a buf |
780 | * @param buf where to write requests to the service | 791 | * @param buf where to write requests to the service |
781 | * @return number of bytes written to buf | 792 | * @return number of bytes written to @a buf |
782 | */ | 793 | */ |
783 | static size_t | 794 | static size_t |
784 | transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | 795 | transmit_watch (struct GNUNET_STATISTICS_Handle *handle, |
796 | size_t size, | ||
797 | void *buf) | ||
785 | { | 798 | { |
786 | struct GNUNET_MessageHeader *hdr; | 799 | struct GNUNET_MessageHeader *hdr; |
787 | size_t slen1; | 800 | size_t slen1; |
@@ -797,7 +810,8 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | |||
797 | reconnect_later (handle); | 810 | reconnect_later (handle); |
798 | return 0; | 811 | return 0; |
799 | } | 812 | } |
800 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting watch request for `%s'\n", | 813 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
814 | "Transmitting watch request for `%s'\n", | ||
801 | handle->current->name); | 815 | handle->current->name); |
802 | slen1 = strlen (handle->current->subsystem) + 1; | 816 | slen1 = strlen (handle->current->subsystem) + 1; |
803 | slen2 = strlen (handle->current->name) + 1; | 817 | slen2 = strlen (handle->current->name) + 1; |
@@ -827,12 +841,14 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | |||
827 | * Transmit a SET/UPDATE request. | 841 | * Transmit a SET/UPDATE request. |
828 | * | 842 | * |
829 | * @param handle statistics handle | 843 | * @param handle statistics handle |
830 | * @param size how many bytes can we write to buf | 844 | * @param size how many bytes can we write to @a buf |
831 | * @param buf where to write requests to the service | 845 | * @param buf where to write requests to the service |
832 | * @return number of bytes written to buf | 846 | * @return number of bytes written to @a buf |
833 | */ | 847 | */ |
834 | static size_t | 848 | static size_t |
835 | transmit_set (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | 849 | transmit_set (struct GNUNET_STATISTICS_Handle *handle, |
850 | size_t size, | ||
851 | void *buf) | ||
836 | { | 852 | { |
837 | struct GNUNET_STATISTICS_SetMessage *r; | 853 | struct GNUNET_STATISTICS_SetMessage *r; |
838 | size_t slen; | 854 | size_t slen; |
@@ -879,10 +895,10 @@ transmit_set (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) | |||
879 | /** | 895 | /** |
880 | * Function called when we are ready to transmit a request to the service. | 896 | * Function called when we are ready to transmit a request to the service. |
881 | * | 897 | * |
882 | * @param cls the 'struct GNUNET_STATISTICS_Handle' | 898 | * @param cls the `struct GNUNET_STATISTICS_Handle` |
883 | * @param size how many bytes can we write to buf | 899 | * @param size how many bytes can we write to @a buf |
884 | * @param buf where to write requests to the service | 900 | * @param buf where to write requests to the service |
885 | * @return number of bytes written to buf | 901 | * @return number of bytes written to @a buf |
886 | */ | 902 | */ |
887 | static size_t | 903 | static size_t |
888 | transmit_action (void *cls, size_t size, void *buf) | 904 | transmit_action (void *cls, size_t size, void *buf) |
@@ -945,11 +961,12 @@ GNUNET_STATISTICS_create (const char *subsystem, | |||
945 | * it). | 961 | * it). |
946 | * | 962 | * |
947 | * @param h statistics handle to destroy | 963 | * @param h statistics handle to destroy |
948 | * @param sync_first set to GNUNET_YES if pending SET requests should | 964 | * @param sync_first set to #GNUNET_YES if pending SET requests should |
949 | * be completed | 965 | * be completed |
950 | */ | 966 | */ |
951 | void | 967 | void |
952 | GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) | 968 | GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, |
969 | int sync_first) | ||
953 | { | 970 | { |
954 | struct GNUNET_STATISTICS_GetHandle *pos; | 971 | struct GNUNET_STATISTICS_GetHandle *pos; |
955 | struct GNUNET_STATISTICS_GetHandle *next; | 972 | struct GNUNET_STATISTICS_GetHandle *next; |
@@ -970,8 +987,11 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) | |||
970 | { | 987 | { |
971 | if (ACTION_GET == h->current->type) | 988 | if (ACTION_GET == h->current->type) |
972 | { | 989 | { |
973 | GNUNET_CLIENT_notify_transmit_ready_cancel (h->th); | 990 | if (NULL != h->th) |
974 | h->th = NULL; | 991 | { |
992 | GNUNET_CLIENT_notify_transmit_ready_cancel (h->th); | ||
993 | h->th = NULL; | ||
994 | } | ||
975 | free_action_item (h->current); | 995 | free_action_item (h->current); |
976 | h->current = NULL; | 996 | h->current = NULL; |
977 | } | 997 | } |
@@ -1034,10 +1054,10 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) | |||
1034 | * confirm that the service has received all of our 'SET' | 1054 | * confirm that the service has received all of our 'SET' |
1035 | * messages (during statistics disconnect/shutdown). | 1055 | * messages (during statistics disconnect/shutdown). |
1036 | * | 1056 | * |
1037 | * @param cls the 'struct GNUNET_STATISTICS_Handle' | 1057 | * @param cls the `struct GNUNET_STATISTICS_Handle` |
1038 | * @param size how many bytes can we write to buf | 1058 | * @param size how many bytes can we write to @a buf |
1039 | * @param buf where to write requests to the service | 1059 | * @param buf where to write requests to the service |
1040 | * @return number of bytes written to buf | 1060 | * @return number of bytes written to @a buf |
1041 | */ | 1061 | */ |
1042 | static size_t | 1062 | static size_t |
1043 | transmit_test_on_shutdown (void *cls, | 1063 | transmit_test_on_shutdown (void *cls, |
@@ -1132,7 +1152,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) | |||
1132 | * @param cont continuation to call when done (can be NULL) | 1152 | * @param cont continuation to call when done (can be NULL) |
1133 | * This callback CANNOT destroy the statistics handle in the same call. | 1153 | * This callback CANNOT destroy the statistics handle in the same call. |
1134 | * @param proc function to call on each value | 1154 | * @param proc function to call on each value |
1135 | * @param cls closure for cont and proc | 1155 | * @param cls closure for @a cont and @a proc |
1136 | * @return NULL on error | 1156 | * @return NULL on error |
1137 | */ | 1157 | */ |
1138 | struct GNUNET_STATISTICS_GetHandle * | 1158 | struct GNUNET_STATISTICS_GetHandle * |
@@ -1208,8 +1228,8 @@ GNUNET_STATISTICS_get_cancel (struct GNUNET_STATISTICS_GetHandle *gh) | |||
1208 | * @param subsystem limit to the specified subsystem, never NULL | 1228 | * @param subsystem limit to the specified subsystem, never NULL |
1209 | * @param name name of the statistic value, never NULL | 1229 | * @param name name of the statistic value, never NULL |
1210 | * @param proc function to call on each value | 1230 | * @param proc function to call on each value |
1211 | * @param proc_cls closure for proc | 1231 | * @param proc_cls closure for @a proc |
1212 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 1232 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
1213 | */ | 1233 | */ |
1214 | int | 1234 | int |
1215 | GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, | 1235 | GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, |
@@ -1238,13 +1258,15 @@ GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, | |||
1238 | * @param subsystem limit to the specified subsystem, never NULL | 1258 | * @param subsystem limit to the specified subsystem, never NULL |
1239 | * @param name name of the statistic value, never NULL | 1259 | * @param name name of the statistic value, never NULL |
1240 | * @param proc function to call on each value | 1260 | * @param proc function to call on each value |
1241 | * @param proc_cls closure for proc | 1261 | * @param proc_cls closure for @a proc |
1242 | * @return GNUNET_OK on success, GNUNET_SYSERR on error (no such watch) | 1262 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (no such watch) |
1243 | */ | 1263 | */ |
1244 | int | 1264 | int |
1245 | GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle, | 1265 | GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle, |
1246 | const char *subsystem, const char *name, | 1266 | const char *subsystem, |
1247 | GNUNET_STATISTICS_Iterator proc, void *proc_cls) | 1267 | const char *name, |
1268 | GNUNET_STATISTICS_Iterator proc, | ||
1269 | void *proc_cls) | ||
1248 | { | 1270 | { |
1249 | struct GNUNET_STATISTICS_WatchEntry *w; | 1271 | struct GNUNET_STATISTICS_WatchEntry *w; |
1250 | unsigned int i; | 1272 | unsigned int i; |
@@ -1280,11 +1302,14 @@ GNUNET_STATISTICS_watch_cancel (struct GNUNET_STATISTICS_Handle *handle, | |||
1280 | * @param name name of the value | 1302 | * @param name name of the value |
1281 | * @param make_persistent should the value be kept across restarts? | 1303 | * @param make_persistent should the value be kept across restarts? |
1282 | * @param value new value or change | 1304 | * @param value new value or change |
1283 | * @param type type of the action (ACTION_SET or ACTION_UPDATE) | 1305 | * @param type type of the action (#ACTION_SET or #ACTION_UPDATE) |
1284 | */ | 1306 | */ |
1285 | static void | 1307 | static void |
1286 | add_setter_action (struct GNUNET_STATISTICS_Handle *h, const char *name, | 1308 | add_setter_action (struct GNUNET_STATISTICS_Handle *h, |
1287 | int make_persistent, uint64_t value, enum ActionType type) | 1309 | const char *name, |
1310 | int make_persistent, | ||
1311 | uint64_t value, | ||
1312 | enum ActionType type) | ||
1288 | { | 1313 | { |
1289 | struct GNUNET_STATISTICS_GetHandle *ai; | 1314 | struct GNUNET_STATISTICS_GetHandle *ai; |
1290 | size_t slen; | 1315 | size_t slen; |
@@ -1292,8 +1317,6 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, const char *name, | |||
1292 | size_t nsize; | 1317 | size_t nsize; |
1293 | int64_t delta; | 1318 | int64_t delta; |
1294 | 1319 | ||
1295 | GNUNET_assert (NULL != h); | ||
1296 | GNUNET_assert (NULL != name); | ||
1297 | slen = strlen (h->subsystem) + 1; | 1320 | slen = strlen (h->subsystem) + 1; |
1298 | nlen = strlen (name) + 1; | 1321 | nlen = strlen (name) + 1; |
1299 | nsize = sizeof (struct GNUNET_STATISTICS_SetMessage) + slen + nlen; | 1322 | nsize = sizeof (struct GNUNET_STATISTICS_SetMessage) + slen + nlen; |
@@ -1380,7 +1403,9 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, const char *name, | |||
1380 | */ | 1403 | */ |
1381 | void | 1404 | void |
1382 | GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle, | 1405 | GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle, |
1383 | const char *name, uint64_t value, int make_persistent) | 1406 | const char *name, |
1407 | uint64_t value, | ||
1408 | int make_persistent) | ||
1384 | { | 1409 | { |
1385 | if (NULL == handle) | 1410 | if (NULL == handle) |
1386 | return; | 1411 | return; |
@@ -1400,14 +1425,19 @@ GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle, | |||
1400 | */ | 1425 | */ |
1401 | void | 1426 | void |
1402 | GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle, | 1427 | GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle, |
1403 | const char *name, int64_t delta, int make_persistent) | 1428 | const char *name, |
1429 | int64_t delta, | ||
1430 | int make_persistent) | ||
1404 | { | 1431 | { |
1405 | if (NULL == handle) | 1432 | if (NULL == handle) |
1406 | return; | 1433 | return; |
1407 | if (0 == delta) | 1434 | if (0 == delta) |
1408 | return; | 1435 | return; |
1409 | GNUNET_assert (GNUNET_NO == handle->do_destroy); | 1436 | GNUNET_assert (GNUNET_NO == handle->do_destroy); |
1410 | add_setter_action (handle, name, make_persistent, (uint64_t) delta, | 1437 | add_setter_action (handle, |
1438 | name, | ||
1439 | make_persistent, | ||
1440 | (uint64_t) delta, | ||
1411 | ACTION_UPDATE); | 1441 | ACTION_UPDATE); |
1412 | } | 1442 | } |
1413 | 1443 | ||