summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2018-11-27 15:52:51 +0000
committercheloha <cheloha@cvs.openbsd.org>2018-11-27 15:52:51 +0000
commit2f489db3dbdfbd3f8634eb6614e14c6a2c38ac7d (patch)
tree4ea4b797db1de6e23304c1db374959c7781c7fea /sys/kern
parent7d902a44685658a35afbb7b619ed5e928a408b7b (diff)
EVFILT_TIMER: Remove extra tick from tvtohz(9) on timeout reload.
tvtohz(9) adds an extra tick to account for the present tick, but this tick needs to be removed when the timeout is reloaded thereafter. We already do this for periodic setitimer(2) timeouts. Prompted by Paul Herman's writeup on clock aliasing for DragonflyBSD: https://frenchfries.net/paul/dfly/nanosleep.html Also fixed in FreeBSD r238424. Style tweaks from visa. ok visa@, guenther@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_event.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index 8a4ede8ae90..755c53ec86c 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_event.c,v 1.100 2018/11/17 18:55:50 millert Exp $ */
+/* $OpenBSD: kern_event.c,v 1.101 2018/11/27 15:52:50 cheloha Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -328,12 +328,16 @@ static void
filt_timer_timeout_add(struct knote *kn)
{
struct timeval tv;
+ struct timeout *to = kn->kn_hook;
int tticks;
tv.tv_sec = kn->kn_sdata / 1000;
tv.tv_usec = (kn->kn_sdata % 1000) * 1000;
tticks = tvtohz(&tv);
- timeout_add(kn->kn_hook, tticks ? tticks : 1);
+ /* Remove extra tick from tvtohz() if timeout has fired before. */
+ if (timeout_triggered(to))
+ tticks--;
+ timeout_add(to, (tticks > 0) ? tticks : 1);
}
void