aboutsummaryrefslogtreecommitdiff
path: root/src/statistics/gnunet-service-statistics.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/statistics/gnunet-service-statistics.c')
-rw-r--r--src/statistics/gnunet-service-statistics.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c
index acf2a965f..6c3d173c4 100644
--- a/src/statistics/gnunet-service-statistics.c
+++ b/src/statistics/gnunet-service-statistics.c
@@ -241,11 +241,20 @@ load (struct GNUNET_SERVER_Handle *server)
241 struct GNUNET_SERVER_MessageStreamTokenizer *mst; 241 struct GNUNET_SERVER_MessageStreamTokenizer *mst;
242 char *emsg; 242 char *emsg;
243 243
244 fn = GNUNET_DISK_get_home_filename (cfg, "statistics", "statistics.data", 244 if (GNUNET_OK !=
245 NULL); 245 GNUNET_CONFIGURATION_get_value_filename (cfg,
246 if (fn == NULL) 246 "STATISTICS",
247 "DATABASE",
248 &fn))
249 {
250 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
251 "STATISTICS",
252 "DATABASE");
247 return; 253 return;
248 if ((GNUNET_OK != GNUNET_DISK_file_size (fn, &fsize, GNUNET_NO, GNUNET_YES)) || (fsize == 0)) 254 }
255 if ( (GNUNET_OK !=
256 GNUNET_DISK_file_size (fn, &fsize, GNUNET_NO, GNUNET_YES)) ||
257 (0 == fsize) )
249 { 258 {
250 GNUNET_free (fn); 259 GNUNET_free (fn);
251 return; 260 return;
@@ -291,15 +300,22 @@ save ()
291 struct StatsEntry *pos; 300 struct StatsEntry *pos;
292 char *fn; 301 char *fn;
293 struct GNUNET_BIO_WriteHandle *wh; 302 struct GNUNET_BIO_WriteHandle *wh;
294
295 uint16_t size; 303 uint16_t size;
296 unsigned long long total; 304 unsigned long long total;
297 305
298 wh = NULL; 306 if (GNUNET_OK !=
299 fn = GNUNET_DISK_get_home_filename (cfg, "statistics", "statistics.data", 307 GNUNET_CONFIGURATION_get_value_filename (cfg,
300 NULL); 308 "STATISTICS",
301 if (fn != NULL) 309 "DATABASE",
302 wh = GNUNET_BIO_write_open (fn); 310 &fn))
311 {
312 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
313 "STATISTICS",
314 "DATABASE");
315 return;
316 }
317 (void) GNUNET_DISK_directory_create_for_file (fn);
318 wh = GNUNET_BIO_write_open (fn);
303 total = 0; 319 total = 0;
304 while (NULL != (pos = start)) 320 while (NULL != (pos = start))
305 { 321 {