X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fclocks.c;h=879ebf911790e1efd892558efab5c0351509b693;hb=315c388516a4750eab4b64d38f8bddd58b4e5aa4;hp=4a2c37f2923648f80a24953280f35af4bded9ddd;hpb=2cc222051e55d0a01b4d0a42dbafa569c0171cd1;p=netdata.git diff --git a/src/clocks.c b/src/clocks.c index 4a2c37f2..879ebf91 100644 --- a/src/clocks.c +++ b/src/clocks.c @@ -27,8 +27,13 @@ static inline usec_t now_usec(clockid_t clk_id) { static inline int now_timeval(clockid_t clk_id, struct timeval *tv) { struct timespec ts; - if(unlikely(clock_gettime(clk_id, &ts) == -1)) + + if(unlikely(clock_gettime(clk_id, &ts) == -1)) { + tv->tv_sec = 0; + tv->tv_usec = 0; return -1; + } + tv->tv_sec = ts.tv_sec; tv->tv_usec = (suseconds_t)((ts.tv_nsec % NSEC_PER_SEC) / NSEC_PER_USEC); return 0;