aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_time.c
diff options
context:
space:
mode:
authorDavid Xu <davidxu@FreeBSD.org>2008-10-20 02:37:53 +0000
committerDavid Xu <davidxu@FreeBSD.org>2008-10-20 02:37:53 +0000
commitd6b6592ec04e16e3abc6dba8f8159989e8ae4594 (patch)
tree01a0b25cf6e6235ebc4f4d67299beba447cd632f /sys/kern/kern_time.c
parent1e63cecbbc48b3d1b1ddc3d36d7b05106ae09429 (diff)
downloadsrc-d6b6592ec04e16e3abc6dba8f8159989e8ae4594.tar.gz
src-d6b6592ec04e16e3abc6dba8f8159989e8ae4594.zip
In realtimer_delete(), clear timer's value and interval to tell
realtimer_expire() to not rearm the timer, otherwise there is a chance that a callout will be left there and be tiggered in future unexpectly. Bug reported by: tegge@
Notes
Notes: svn path=/head/; revision=184067
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r--sys/kern/kern_time.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 366da9da5007..7ccbb6a0b40e 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1242,6 +1242,12 @@ realtimer_delete(struct itimer *it)
{
mtx_assert(&it->it_mtx, MA_OWNED);
+ /*
+ * clear timer's value and interval to tell realtimer_expire
+ * to not rearm the timer.
+ */
+ timespecclear(&it->it_time.it_value);
+ timespecclear(&it->it_time.it_interval);
ITIMER_UNLOCK(it);
callout_drain(&it->it_callout);
ITIMER_LOCK(it);
@@ -1391,9 +1397,11 @@ realtimer_expire(void *arg)
callout_reset(&it->it_callout, tvtohz(&tv),
realtimer_expire, it);
}
+ itimer_enter(it);
ITIMER_UNLOCK(it);
itimer_fire(it);
ITIMER_LOCK(it);
+ itimer_leave(it);
} else if (timespecisset(&it->it_time.it_value)) {
ts = it->it_time.it_value;
timespecsub(&ts, &cts);