diff options
author | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-03-19 10:48:51 +0000 |
---|---|---|
committer | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-03-19 10:48:51 +0000 |
commit | 41d15781f67e4250a53b7512afd29221fe2b7fdc (patch) | |
tree | 657a7cd7a327aad0e7598b3d28cecc0d5cd95cd4 /src/statistics | |
parent | fb1ebd430a77a956f9fced8045e0d57fd237f1c0 (diff) |
-LRN: calculate file size for single files when needed and use GNUNET_DISK_file_size instead of STAT
git-svn-id: https://gnunet.org/svn/gnunet@20600 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/statistics')
-rw-r--r-- | src/statistics/gnunet-service-statistics.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 58ef763e3a..1ec07ad5dc 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c @@ -224,6 +224,7 @@ load (struct GNUNET_SERVER_Handle *server) char *fn; struct GNUNET_BIO_ReadHandle *rh; struct stat sb; + uint64_t fsize; char *buf; struct GNUNET_SERVER_MessageStreamTokenizer *mst; char *emsg; @@ -232,12 +233,12 @@ load (struct GNUNET_SERVER_Handle *server) NULL); if (fn == NULL) return; - if ((0 != stat (fn, &sb)) || (sb.st_size == 0)) + if ((GNUNET_OK != GNUNET_DISK_file_size (fn, &fsize, GNUNET_NO, GNUNET_YES)) || (fsize == 0)) { GNUNET_free (fn); return; } - buf = GNUNET_malloc (sb.st_size); + buf = GNUNET_malloc (fsize); rh = GNUNET_BIO_read_open (fn); if (!rh) { @@ -245,7 +246,7 @@ load (struct GNUNET_SERVER_Handle *server) GNUNET_free (fn); return; } - if (GNUNET_OK != GNUNET_BIO_read (rh, fn, buf, sb.st_size)) + if (GNUNET_OK != GNUNET_BIO_read (rh, fn, buf, fsize)) { GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "read", fn); GNUNET_break (GNUNET_OK == GNUNET_BIO_read_close (rh, &emsg)); @@ -256,10 +257,10 @@ load (struct GNUNET_SERVER_Handle *server) } GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading %llu bytes of statistics from `%s'\n"), - (unsigned long long) sb.st_size, fn); + fsize, fn); mst = GNUNET_SERVER_mst_create (&inject_message, server); GNUNET_break (GNUNET_OK == - GNUNET_SERVER_mst_receive (mst, NULL, buf, sb.st_size, + GNUNET_SERVER_mst_receive (mst, NULL, buf, fsize, GNUNET_YES, GNUNET_NO)); GNUNET_SERVER_mst_destroy (mst); GNUNET_free (buf); |