summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2019-04-30 15:51:54 +0000
committercheloha <cheloha@cvs.openbsd.org>2019-04-30 15:51:54 +0000
commitaf35c28598af6789cb7eb1937fa03fd12e565bd5 (patch)
tree3983bdba633b7392a4fbad6f238bd499c91b6e35 /sys
parentbba725a5699d77dcd70f4c7ca50955a77199c229 (diff)
tc_setclock: always call tc_windup() before leaving windup_mtx.
We ought to conform to the windup_mtx protocol and call tc_windup() even if we aren't changing the system uptime.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_tc.c21
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);