diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-05-08 13:33:51 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-05-08 13:33:51 +0000 |
commit | b7d2254d7c2b838f8b52b36d05210bab5fe3bae9 (patch) | |
tree | 18b58774da9762e61e309f32f3d2a6e686be83dd | |
parent | 087280973a36b24206dabd2d866a19967d66d211 (diff) | |
download | gnunet-b7d2254d7c2b838f8b52b36d05210bab5fe3bae9.tar.gz gnunet-b7d2254d7c2b838f8b52b36d05210bab5fe3bae9.zip |
- Document statistics api and fix testing's usage of it
-rw-r--r-- | src/include/gnunet_statistics_service.h | 1 | ||||
-rw-r--r-- | src/statistics/statistics_api.c | 1 | ||||
-rw-r--r-- | src/testing/testing_group.c | 24 |
3 files changed, 23 insertions, 3 deletions
diff --git a/src/include/gnunet_statistics_service.h b/src/include/gnunet_statistics_service.h index bfd65f883..051533182 100644 --- a/src/include/gnunet_statistics_service.h +++ b/src/include/gnunet_statistics_service.h | |||
@@ -145,6 +145,7 @@ struct GNUNET_STATISTICS_GetHandle; | |||
145 | * @param timeout after how long should we give up (and call | 145 | * @param timeout after how long should we give up (and call |
146 | * notify with buf NULL and size 0)? | 146 | * notify with buf NULL and size 0)? |
147 | * @param cont continuation to call when done (can be NULL) | 147 | * @param cont continuation to call when done (can be NULL) |
148 | * This callback CANNOT destroy the statistics handle in the same call. | ||
148 | * @param proc function to call on each value | 149 | * @param proc function to call on each value |
149 | * @param cls closure for proc and cont | 150 | * @param cls closure for proc and cont |
150 | * @return NULL on error | 151 | * @return NULL on error |
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 0533ff950..e1b3698e6 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c | |||
@@ -1075,6 +1075,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) | |||
1075 | * @param timeout after how long should we give up (and call | 1075 | * @param timeout after how long should we give up (and call |
1076 | * cont with an error code)? | 1076 | * cont with an error code)? |
1077 | * @param cont continuation to call when done (can be NULL) | 1077 | * @param cont continuation to call when done (can be NULL) |
1078 | * This callback CANNOT destroy the statistics handle in the same call. | ||
1078 | * @param proc function to call on each value | 1079 | * @param proc function to call on each value |
1079 | * @param cls closure for cont and proc | 1080 | * @param cls closure for cont and proc |
1080 | * @return NULL on error | 1081 | * @return NULL on error |
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 607d455b6..40cab604b 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -4884,6 +4884,22 @@ internal_stats_callback (void *cls, const char *subsystem, const char *name, | |||
4884 | subsystem, name, value, is_persistent); | 4884 | subsystem, name, value, is_persistent); |
4885 | } | 4885 | } |
4886 | 4886 | ||
4887 | |||
4888 | /** | ||
4889 | * We don't need the statistics handle anymore, destroy it. | ||
4890 | * | ||
4891 | * @param cls Closure (the statistics handle to destroy) | ||
4892 | * @param tc Task Context | ||
4893 | */ | ||
4894 | static void | ||
4895 | internal_destroy_statistics (void *cls, GNUNET_SCHEDULER_TaskContext *tc) | ||
4896 | { | ||
4897 | struct GNUNET_STATISTICS_Handle *h = cls; | ||
4898 | |||
4899 | GNUNET_STATISTICS_destroy (h, GNUNET_NO); | ||
4900 | } | ||
4901 | |||
4902 | |||
4887 | /** | 4903 | /** |
4888 | * Internal continuation call for statistics iteration. | 4904 | * Internal continuation call for statistics iteration. |
4889 | * | 4905 | * |
@@ -4908,7 +4924,9 @@ internal_stats_cont (void *cls, int success) | |||
4908 | } | 4924 | } |
4909 | 4925 | ||
4910 | if (core_context->stats_handle != NULL) | 4926 | if (core_context->stats_handle != NULL) |
4911 | GNUNET_STATISTICS_destroy (core_context->stats_handle, GNUNET_NO); | 4927 | /* Cannot destroy handle inside the continuation */ |
4928 | GNUNET_SCHEDULER_add_now (&internal_destroy_statistics, | ||
4929 | core_context->stats_handle); | ||
4912 | 4930 | ||
4913 | GNUNET_free (core_context); | 4931 | GNUNET_free (core_context); |
4914 | } | 4932 | } |
@@ -5290,9 +5308,9 @@ increment_outstanding_at_host (const char *hostname, | |||
5290 | struct OutstandingSSH *pos; | 5308 | struct OutstandingSSH *pos; |
5291 | 5309 | ||
5292 | pos = pg->ssh_head; | 5310 | pos = pg->ssh_head; |
5293 | while ((pos != NULL) && (strcmp (pos->hostname, hostname) != 0)) | 5311 | while ((NULL != pos) && (strcmp (pos->hostname, hostname) != 0)) |
5294 | pos = pos->next; | 5312 | pos = pos->next; |
5295 | GNUNET_assert (pos != NULL); | 5313 | GNUNET_assert (NULL != pos); |
5296 | pos->outstanding++; | 5314 | pos->outstanding++; |
5297 | } | 5315 | } |
5298 | 5316 | ||