backend: fix off-by-one in nsec calculation
authorJens Axboe <axboe@fb.com>
Mon, 15 Dec 2014 20:45:53 +0000 (13:45 -0700)
committerJens Axboe <axboe@fb.com>
Mon, 15 Dec 2014 20:45:53 +0000 (13:45 -0700)
If it's equal to 10^9 we need to bump seconds and subtract 10^9
from nsec, not only if it's larger than.

Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c

index 3424a0982b534bc60b8ea037814427e9156b929f..f1def38b36b7898865eff2d3c86b8a0ee0fc3eae 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -2109,7 +2109,7 @@ static void *helper_thread_main(void *data)
                gettimeofday(&tv, NULL);
                ts.tv_sec = tv.tv_sec + sec;
                ts.tv_nsec = (tv.tv_usec * 1000) + nsec;
-               if (ts.tv_nsec > 1000000000ULL) {
+               if (ts.tv_nsec >= 1000000000ULL) {
                        ts.tv_nsec -= 1000000000ULL;
                        ts.tv_sec++;
                }