From 79d5b1bf3bfebdc96ad717b0ebf1d9bc62182b0b Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 26 Nov 2014 21:29:13 +0000 Subject: stop using gettimeofday and use the monotonic time interface fron nsutils --- Makefile | 3 ++- content/llcache.c | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 976815e8b..b37dcba22 100644 --- a/Makefile +++ b/Makefile @@ -493,7 +493,8 @@ $(eval $(call feature_switch,HARU_PDF,PDF export (haru),-DWITH_PDF_EXPORT,-lhpdf $(eval $(call feature_switch,LIBICONV_PLUG,glibc internal iconv,-DLIBICONV_PLUG,,-ULIBICONV_PLUG,-liconv)) # Common libraries with pkgconfig -$(eval $(call pkg_config_find_and_add,libutf8proc,UTF8PROC)) +$(eval $(call pkg_config_find_and_add,libutf8proc,utf8proc)) +$(eval $(call pkg_config_find_and_add,libnsutils,nsutils)) # Common libraries without pkg-config support LDFLAGS += -lz diff --git a/content/llcache.c b/content/llcache.c index e97beb97e..3c46a6d22 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -36,8 +36,10 @@ */ #include +#include #include #include +#include #include "utils/config.h" @@ -2306,11 +2308,10 @@ write_backing_store(struct llcache_object *object, size_t *written_out, unsigned nserror ret; uint8_t *metadata; size_t metadatasize; - struct timeval start_tv; - struct timeval end_tv; - struct timeval elapsed_tv; + uint64_t startms = 0; + uint64_t endms = 1000; - gettimeofday(&start_tv, NULL); + nsu_getmonotonic_ms(&startms); /* put object data in backing store */ ret = guit->llcache->store(object->url, @@ -2343,15 +2344,16 @@ write_backing_store(struct llcache_object *object, size_t *written_out, unsigned guit->llcache->invalidate(object->url); return ret; } - gettimeofday(&end_tv, NULL); - - timersub(&end_tv, &start_tv, &elapsed_tv); + nsu_getmonotonic_ms(&endms); object->store_state = LLCACHE_STATE_DISC; *written_out = object->source_len + metadatasize; - *elapsed = (elapsed_tv.tv_sec * 1000) + (elapsed_tv.tv_usec / 1000); + /* by ignoring the overflow this assumes the writeout took + * less than 5 weeks. + */ + *elapsed = endms - startms; return NSERROR_OK; } -- cgit v1.2.3