summaryrefslogtreecommitdiffstats
path: root/sys-utils/hwclock-rtc.c
diff options
context:
space:
mode:
authorSami Kerola2019-01-07 22:34:11 +0100
committerSami Kerola2019-01-12 09:46:54 +0100
commitf78a90217447b10cb52c2789d88da07088b37425 (patch)
tree76b4cb8d6a1fa5e29cf38c3c0af1bde76cf1bf40 /sys-utils/hwclock-rtc.c
parentinclude: add indirect monotonic clock id specifier (diff)
downloadkernel-qcow2-util-linux-f78a90217447b10cb52c2789d88da07088b37425.tar.gz
kernel-qcow2-util-linux-f78a90217447b10cb52c2789d88da07088b37425.tar.xz
kernel-qcow2-util-linux-f78a90217447b10cb52c2789d88da07088b37425.zip
hwclock: use monotonic time to measure how long setting time takes
Earlier gettimeofday() was affected by discontinuous jumps. Measuring how long time it takes to set time using function that effected by the very thing being measured makes head spin. Lets make this less confusing with monotonic clock that ticks on without jumps. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/hwclock-rtc.c')
-rw-r--r--sys-utils/hwclock-rtc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys-utils/hwclock-rtc.c b/sys-utils/hwclock-rtc.c
index 32feb3504..a0d28f89e 100644
--- a/sys-utils/hwclock-rtc.c
+++ b/sys-utils/hwclock-rtc.c
@@ -12,6 +12,7 @@
#include <time.h>
#include <unistd.h>
+#include "monotonic.h"
#include "nls.h"
#include "hwclock.h"
@@ -223,12 +224,12 @@ static int busywait_for_rtc_clock_tick(const struct hwclock_control *ctl,
* something weird happens, we have a time limit (1.5s) on this loop
* to reduce the impact of this failure.
*/
- gettimeofday(&begin, NULL);
+ gettime_monotonic(&begin);
do {
rc = do_rtc_read_ioctl(rtc_fd, &nowtime);
if (rc || start_time.tm_sec != nowtime.tm_sec)
break;
- gettimeofday(&now, NULL);
+ gettime_monotonic(&now);
if (time_diff(now, begin) > 1.5) {
warnx(_("Timed out waiting for time change."));
return 1;