X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Ftime.h;h=288922d8a839533ece3531136a6dc2c66b595dd1;hb=b9f2cf0bff89ccf5c88072213a25efb65fb5516e;hp=3fdc7d43ea876eb5cfe7ad9bcdaf27408eac4c10;hpb=a3db0782d4c069733fa2e3ac1763efd4499b1de7;p=vpp.git diff --git a/src/vppinfra/time.h b/src/vppinfra/time.h index 3fdc7d43ea8..288922d8a83 100644 --- a/src/vppinfra/time.h +++ b/src/vppinfra/time.h @@ -263,10 +263,12 @@ unix_usage_now (void) always_inline void unix_sleep (f64 dt) { - struct timespec t; - t.tv_sec = dt; - t.tv_nsec = 1e9 * dt; - nanosleep (&t, 0); + struct timespec ts, tsrem; + ts.tv_sec = dt; + ts.tv_nsec = 1e9 * (dt - (f64) ts.tv_sec); + + while (nanosleep (&ts, &tsrem) < 0) + ts = tsrem; } #else /* ! CLIB_UNIX */