diff options
author | Thorsten Lockert <tholo@cvs.openbsd.org> | 2004-06-24 19:35:28 +0000 |
---|---|---|
committer | Thorsten Lockert <tholo@cvs.openbsd.org> | 2004-06-24 19:35:28 +0000 |
commit | c6cc17e855e1d9fe177fba41d00de6e89fdc852e (patch) | |
tree | bdc6bde04c820ca59fe49d60185cf6ac40b44e30 /sys/kern/kern_event.c | |
parent | 128dd71ffeec48b94e085c757b3626553d619e7c (diff) |
This moves access to wall and uptime variables in MI code,
encapsulating all such access into wall-defined functions
that makes sure locking is done as needed.
It also cleans up some uses of wall time vs. uptime some
places, but there is sure to be more of these needed as
well, particularily in MD code. Also, many current calls
to microtime() should probably be changed to getmicrotime(),
or to the {,get}microuptime() versions.
ok art@ deraadt@ aaron@ matthieu@ beck@ sturm@ millert@ others
"Oh, that is not your problem!" from miod@
Diffstat (limited to 'sys/kern/kern_event.c')
-rw-r--r-- | sys/kern/kern_event.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 9d030f4f269..f340617b051 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_event.c,v 1.23 2004/04/01 00:27:51 tedu Exp $ */ +/* $OpenBSD: kern_event.c,v 1.24 2004/06/24 19:35:24 tholo Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> @@ -545,7 +545,7 @@ kqueue_scan(struct file *fp, int maxevents, struct kevent *ulistp, { struct kqueue *kq = (struct kqueue *)fp->f_data; struct kevent *kevp; - struct timeval atv; + struct timeval atv, rtv, ttv; struct knote *kn, marker; int s, count, timeout, nkev = 0, error = 0; @@ -565,10 +565,11 @@ kqueue_scan(struct file *fp, int maxevents, struct kevent *ulistp, goto done; } - s = splclock(); - timeradd(&atv, &time, &atv); - timeout = hzto(&atv); - splx(s); + timeout = atv.tv_sec > 24 * 60 * 60 ? + 24 * 60 * 60 * hz : tvtohz(&atv); + + getmicrouptime(&rtv); + timeradd(&atv, &rtv, &atv); } else { atv.tv_sec = 0; atv.tv_usec = 0; @@ -578,9 +579,13 @@ kqueue_scan(struct file *fp, int maxevents, struct kevent *ulistp, retry: if (atv.tv_sec || atv.tv_usec) { - timeout = hzto(&atv); - if (timeout <= 0) + getmicrouptime(&rtv); + if (timercmp(&rtv, &atv, >=)) goto done; + ttv = atv; + timersub(&ttv, &rtv, &ttv); + timeout = ttv.tv_sec > 24 * 60 * 60 ? + 24 * 60 * 60 * hz : tvtohz(&ttv); } start: |