summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2012-04-10 11:33:58 +0000
committerguenther <guenther@openbsd.org>2012-04-10 11:33:58 +0000
commit2c6affdaa6db4bcc23538641dafa6a73e7f6128b (patch)
tree67684c7ccd3368dc3c01fe2d6ce232e90deb89b2
parentReturn EINVAL on 0-byte mmap invocation. (diff)
downloadwireguard-openbsd-2c6affdaa6db4bcc23538641dafa6a73e7f6128b.tar.xz
wireguard-openbsd-2c6affdaa6db4bcc23538641dafa6a73e7f6128b.zip
When converting the timeout to ticks, both round up and add one to account
for the tick that we're already in the middle of. noted and tested by aja; ok kurt@
-rw-r--r--sys/kern/kern_synch.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 6b10a95e5b9..caa939353e7 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_synch.c,v 1.101 2012/03/23 15:51:26 guenther Exp $ */
+/* $OpenBSD: kern_synch.c,v 1.102 2012/04/10 11:33:58 guenther Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*
@@ -455,11 +455,9 @@ sys___thrsleep(struct proc *p, void *v, register_t *retval)
timespecsub(&ats, &now, &ats);
to_ticks = (long long)hz * ats.tv_sec +
- ats.tv_nsec / (tick * 1000);
+ (ats.tv_nsec + tick * 1000 - 1) / (tick * 1000) + 1;
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
- if (to_ticks == 0)
- to_ticks = 1;
}
p->p_thrslpid = ident;