Author: davidxu
Date: Mon Oct 20 02:37:53 2008
New Revision: 184067
URL: http://svn.freebsd.org/changeset/base/184067

Log:
  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@

Modified:
  head/sys/kern/kern_time.c

Modified: head/sys/kern/kern_time.c
==============================================================================
--- head/sys/kern/kern_time.c   Mon Oct 20 01:46:54 2008        (r184066)
+++ head/sys/kern/kern_time.c   Mon Oct 20 02:37:53 2008        (r184067)
@@ -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);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to