Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Replace callout_stop with callout_halt



details:   https://anonhg.NetBSD.org/src/rev/5e4903930092
branches:  trunk
changeset: 333900:5e4903930092
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Fri Nov 21 09:40:10 2014 +0000

description:
Replace callout_stop with callout_halt

In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.

In this case, we need to pass an interlock to callout_halt to wait for
the callout complete.

Reviewed by riastradh@.

diffstat:

 sys/dev/usb/ohci.c     |  6 +++---
 sys/kern/kern_ktrace.c |  9 +++++----
 2 files changed, 8 insertions(+), 7 deletions(-)

diffs (64 lines):

diff -r b9d9a8749a43 -r 5e4903930092 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Fri Nov 21 08:58:28 2014 +0000
+++ b/sys/dev/usb/ohci.c        Fri Nov 21 09:40:10 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.253 2014/08/05 10:33:46 skrll Exp $ */
+/*     $NetBSD: ohci.c,v 1.254 2014/11/21 09:40:10 ozaki-r Exp $       */
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.253 2014/08/05 10:33:46 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254 2014/11/21 09:40:10 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -350,7 +350,7 @@
        if (rv != 0)
                return (rv);
 
-       callout_stop(&sc->sc_tmo_rhsc);
+       callout_halt(&sc->sc_tmo_rhsc, &sc->sc_lock);
 
        usb_delay_ms(&sc->sc_bus, 300); /* XXX let stray task complete */
        callout_destroy(&sc->sc_tmo_rhsc);
diff -r b9d9a8749a43 -r 5e4903930092 sys/kern/kern_ktrace.c
--- a/sys/kern/kern_ktrace.c    Fri Nov 21 08:58:28 2014 +0000
+++ b/sys/kern/kern_ktrace.c    Fri Nov 21 09:40:10 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_ktrace.c,v 1.165 2014/09/21 17:17:15 christos Exp $       */
+/*     $NetBSD: kern_ktrace.c,v 1.166 2014/11/21 09:40:10 ozaki-r Exp $        */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.165 2014/09/21 17:17:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.166 2014/11/21 09:40:10 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1402,6 +1402,9 @@
        }
 
        TAILQ_REMOVE(&ktdq, ktd, ktd_list);
+
+       callout_halt(&ktd->ktd_wakch, &ktrace_lock);
+       callout_destroy(&ktd->ktd_wakch);
        mutex_exit(&ktrace_lock);
 
        /*
@@ -1415,8 +1418,6 @@
        cv_destroy(&ktd->ktd_sync_cv);
        cv_destroy(&ktd->ktd_cv);
 
-       callout_stop(&ktd->ktd_wakch);
-       callout_destroy(&ktd->ktd_wakch);
        kmem_free(ktd, sizeof(*ktd));
 
        kthread_exit(0);



Home | Main Index | Thread Index | Old Index