summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Harris <pharris@opentext.com>2019-01-30 14:51:07 -0500
committerAdam Jackson <ajax@redhat.com>2019-02-20 14:26:51 -0500
commitae9dda1e2620f402b434f10df581b0fdf0495ee8 (patch)
tree1758d48e0699cf6ada54b1b81cae005fc2cac610
parent013c28a122a61beaf3a4ee7cc92b7ca2c92de7ab (diff)
os: Fix GetTimeInMicros resolution
GetTimeInMillis is called first, which sets clockid to CLOCK_MONOTONIC_COARSE, which is typically much lower resolution than the callers of GetTimeInMicros want. Prior to a779fda224bee0c4d27636503367e55ae93b33c2, GetTimeInMillis and GetTimeInMicros did not share a clockid. Restore the clockid split to fix the granularity of GetTimeInMicros. Signed-off-by: Peter Harris <pharris@opentext.com> (cherry picked from commit 937a5b78a2f6ea771132ff0f9ece708a23c1bdad)
-rw-r--r--os/utils.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/os/utils.c b/os/utils.c
index 6e3c16869..2ba1c8013 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -485,14 +485,15 @@ GetTimeInMicros(void)
struct timeval tv;
#ifdef MONOTONIC_CLOCK
struct timespec tp;
+ static clockid_t uclockid;
- if (!clockid) {
+ if (!uclockid) {
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
- clockid = CLOCK_MONOTONIC;
+ uclockid = CLOCK_MONOTONIC;
else
- clockid = ~0L;
+ uclockid = ~0L;
}
- if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
+ if (uclockid != ~0L && clock_gettime(uclockid, &tp) == 0)
return (CARD64) tp.tv_sec * (CARD64)1000000 + tp.tv_nsec / 1000;
#endif