Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern simplify timeout handling code in kqueue_scan()
details: https://anonhg.NetBSD.org/src/rev/a833dccb7159
branches: trunk
changeset: 543286:a833dccb7159
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Fri Feb 21 20:57:09 2003 +0000
description:
simplify timeout handling code in kqueue_scan()
diffstat:
sys/kern/kern_event.c | 29 +++++++++++++----------------
1 files changed, 13 insertions(+), 16 deletions(-)
diffs (56 lines):
diff -r 6f1398ab7958 -r a833dccb7159 sys/kern/kern_event.c
--- a/sys/kern/kern_event.c Fri Feb 21 20:19:00 2003 +0000
+++ b/sys/kern/kern_event.c Fri Feb 21 20:57:09 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_event.c,v 1.8 2003/02/04 09:02:05 jdolecek Exp $ */
+/* $NetBSD: kern_event.c,v 1.9 2003/02/21 20:57:09 jdolecek Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon%FreeBSD.org@localhost>
* All rights reserved.
@@ -887,7 +887,7 @@
if (count == 0)
goto done;
- if (tsp != NULL) { /* timeout supplied */
+ if (tsp) { /* timeout supplied */
TIMESPEC_TO_TIMEVAL(&atv, tsp);
if (itimerfix(&atv)) {
error = EINVAL;
@@ -896,26 +896,23 @@
s = splclock();
timeradd(&atv, &time, &atv); /* calc. time to wait until */
splx(s);
- if (tsp->tv_sec == 0 && tsp->tv_nsec < 1000 /*<1us*/)
- timeout = -1; /* perform a poll */
- else
- timeout = hzto(&atv); /* calculate hz till timeout */
+ timeout = hzto(&atv);
+ if (timeout <= 0)
+ timeout = -1; /* do poll */
} else {
- atv.tv_sec = 0; /* no timeout, wait forever */
- atv.tv_usec = 0;
+ /* no timeout, wait forever */
timeout = 0;
}
goto start;
retry:
- if (atv.tv_sec || atv.tv_usec) { /* timeout requested */
- s = splclock();
- if (timercmp(&time, &atv, >=)) {
- splx(s);
- goto done; /* timeout reached */
- }
- splx(s);
- timeout = hzto(&atv); /* recalc. timeout remaining */
+ if (tsp) {
+ /*
+ * We have to recalculate the timeout on every retry.
+ */
+ timeout = hzto(&atv);
+ if (timeout <= 0)
+ goto done;
}
start:
Home |
Main Index |
Thread Index |
Old Index