aboutsummaryrefslogtreecommitdiff
path: root/src/statistics
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-11-04 22:42:14 +0000
committerChristian Grothoff <christian@grothoff.org>2012-11-04 22:42:14 +0000
commit04abbfa36d0e4acc9c109d161d1e6e00ced93580 (patch)
treeb8a8c6fed3714f1f0deeb733cd9c7b7c3653c453 /src/statistics
parent10b1bfd1d9d728e4c7834a20116e338a2b0fe429 (diff)
downloadgnunet-04abbfa36d0e4acc9c109d161d1e6e00ced93580.tar.gz
gnunet-04abbfa36d0e4acc9c109d161d1e6e00ced93580.zip
-fix #2609
Diffstat (limited to 'src/statistics')
-rw-r--r--src/statistics/gnunet-statistics.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c
index 2331aace0..97d867272 100644
--- a/src/statistics/gnunet-statistics.c
+++ b/src/statistics/gnunet-statistics.c
@@ -73,6 +73,7 @@ static char *remote_host;
73 */ 73 */
74static unsigned long long remote_port; 74static unsigned long long remote_port;
75 75
76
76/** 77/**
77 * Callback function to process statistic values. 78 * Callback function to process statistic values.
78 * 79 *
@@ -138,17 +139,22 @@ cleanup (void *cls, int success)
138} 139}
139 140
140 141
142/**
143 * Function run on shutdown to clean up.
144 *
145 * @param cls the statistics handle
146 * @param tc scheduler context
147 */
141static void 148static void
142shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 149shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
143{ 150{
144 struct GNUNET_STATISTICS_Handle *h = cls; 151 struct GNUNET_STATISTICS_Handle *h = cls;
145 152
146 if (NULL != h) 153 if (NULL == h)
147 { 154 return;
148 GNUNET_STATISTICS_watch_cancel (h, subsystem, name, &printer, h); 155 GNUNET_STATISTICS_watch_cancel (h, subsystem, name, &printer, h);
149 GNUNET_STATISTICS_destroy (h, GNUNET_NO); 156 GNUNET_STATISTICS_destroy (h, GNUNET_NO);
150 h = NULL; 157 h = NULL;
151 }
152} 158}
153 159
154 160
@@ -210,9 +216,7 @@ run (void *cls, char *const *args, const char *cfgfile,
210 h = NULL; 216 h = NULL;
211 return; 217 return;
212 } 218 }
213 h = GNUNET_STATISTICS_create ("gnunet-statistics", cfg); 219 if (NULL == (h = GNUNET_STATISTICS_create ("gnunet-statistics", cfg)))
214 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, h);
215 if (NULL == h)
216 { 220 {
217 ret = 1; 221 ret = 1;
218 return; 222 return;
@@ -229,8 +233,8 @@ run (void *cls, char *const *args, const char *cfgfile,
229 if ((NULL == subsystem) || (NULL == name)) 233 if ((NULL == subsystem) || (NULL == name))
230 { 234 {
231 printf (_("No subsystem or name given\n")); 235 printf (_("No subsystem or name given\n"));
232 if (h != NULL) 236 GNUNET_STATISTICS_destroy (h, GNUNET_NO);
233 GNUNET_STATISTICS_destroy (h, GNUNET_NO); 237 h = NULL;
234 ret = 1; 238 ret = 1;
235 return; 239 return;
236 } 240 }
@@ -241,8 +245,11 @@ run (void *cls, char *const *args, const char *cfgfile,
241 return; 245 return;
242 } 246 }
243 } 247 }
248 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
249 &shutdown_task, h);
244} 250}
245 251
252
246/** 253/**
247 * The main function to obtain statistics in GNUnet. 254 * The main function to obtain statistics in GNUnet.
248 * 255 *