diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_tc.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 2e426238564..fe68615a869 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_tc.c,v 1.43 2019/03/25 23:32:00 cheloha Exp $ */ +/* $OpenBSD: kern_tc.c,v 1.44 2019/04/30 15:51:53 cheloha Exp $ */ /* * Copyright (c) 2000 Poul-Henning Kamp <phk@FreeBSD.org> @@ -400,6 +400,7 @@ tc_setclock(const struct timespec *ts) struct bintime bt, bt2; struct timespec earlier; static int first = 1; + int rewind = 0; #ifndef SMALL_KERNEL long long adj_ticks; #endif @@ -425,20 +426,22 @@ tc_setclock(const struct timespec *ts) */ if (bt.sec < timehands->th_offset.sec || (bt.sec == timehands->th_offset.sec && - bt.frac < timehands->th_offset.frac)) { - mtx_leave(&windup_mtx); - bintime2timespec(&bt, &earlier); - printf("%s: cannot rewind uptime to %lld.%09ld\n", - __func__, (long long)earlier.tv_sec, earlier.tv_nsec); - return; - } + bt.frac < timehands->th_offset.frac)) + rewind = 1; bt2 = timehands->th_offset; /* XXX fiddle all the little crinkly bits around the fiords... */ - tc_windup(NULL, &bt, NULL); + tc_windup(NULL, rewind ? NULL : &bt, NULL); mtx_leave(&windup_mtx); + if (rewind) { + bintime2timespec(&bt, &earlier); + printf("%s: cannot rewind uptime to %lld.%09ld\n", + __func__, (long long)earlier.tv_sec, earlier.tv_nsec); + return; + } + #ifndef SMALL_KERNEL /* convert the bintime to ticks */ bintime_sub(&bt, &bt2); |