Module Name:    src
Committed By:   jmcneill
Date:           Sun Jan 15 10:51:13 UTC 2012

Modified Files:
        src/sys/arch/usermode/dev: if_veth.c vaudio.c

Log Message:
close file descriptors at shutdown


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/dev/if_veth.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/dev/vaudio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/usermode/dev/if_veth.c
diff -u src/sys/arch/usermode/dev/if_veth.c:1.3 src/sys/arch/usermode/dev/if_veth.c:1.4
--- src/sys/arch/usermode/dev/if_veth.c:1.3	Mon Jan  9 20:39:39 2012
+++ src/sys/arch/usermode/dev/if_veth.c	Sun Jan 15 10:51:12 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: if_veth.c,v 1.3 2012/01/09 20:39:39 reinoud Exp $ */
+/* $NetBSD: if_veth.c,v 1.4 2012/01/15 10:51:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.3 2012/01/09 20:39:39 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.4 2012/01/15 10:51:12 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 
 
 static int	veth_match(device_t, cfdata_t, void *);
 static void	veth_attach(device_t, device_t, void *);
+static bool	veth_shutdown(device_t, int);
 
 static int	veth_init(struct ifnet *);
 static void	veth_start(struct ifnet *);
@@ -103,6 +104,9 @@ veth_attach(device_t parent, device_t se
 	struct ifnet *ifp = &sc->sc_ec.ec_if;
 
 	sc->sc_dev = self;
+
+	pmf_device_register1(self, NULL, NULL, veth_shutdown);
+
 	sc->sc_tapfd = thunk_open_tap(taa->u.veth.device);
 	if (sc->sc_tapfd == -1) {
 		aprint_error(": couldn't open %s: %d\n",
@@ -156,6 +160,17 @@ veth_attach(device_t parent, device_t se
 		panic("couldn't establish veth rx interrupt");
 }
 
+static bool
+veth_shutdown(device_t self, int flags)
+{
+	struct veth_softc *sc = device_private(self);
+
+	if (sc->sc_tapfd != -1)
+		thunk_close(sc->sc_tapfd);
+
+	return true;
+}
+
 static int
 veth_init(struct ifnet *ifp)
 {

Index: src/sys/arch/usermode/dev/vaudio.c
diff -u src/sys/arch/usermode/dev/vaudio.c:1.2 src/sys/arch/usermode/dev/vaudio.c:1.3
--- src/sys/arch/usermode/dev/vaudio.c:1.2	Mon Dec 26 23:50:43 2011
+++ src/sys/arch/usermode/dev/vaudio.c	Sun Jan 15 10:51:12 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: vaudio.c,v 1.2 2011/12/26 23:50:43 jmcneill Exp $ */
+/* $NetBSD: vaudio.c,v 1.3 2012/01/15 10:51:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.2 2011/12/26 23:50:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.3 2012/01/15 10:51:12 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -76,6 +76,7 @@ struct vaudio_softc {
 
 static int	vaudio_match(device_t, cfdata_t, void *);
 static void	vaudio_attach(device_t, device_t, void *);
+static bool	vaudio_shutdown(device_t, int);
 
 static void	vaudio_intr(void *);
 static void	vaudio_softintr_play(void *);
@@ -148,6 +149,9 @@ vaudio_attach(device_t parent, device_t 
 	aprint_normal(": Virtual Audio (device = %s)\n", taa->u.vaudio.device);
 
 	sc->sc_dev = self;
+
+	pmf_device_register1(self, NULL, NULL, vaudio_shutdown);
+
 	sc->sc_audiopath = taa->u.vaudio.device;
 	sc->sc_audiofd = thunk_audio_open(sc->sc_audiopath);
 	if (sc->sc_audiofd == -1) {
@@ -181,6 +185,17 @@ vaudio_attach(device_t parent, device_t 
 	sc->sc_audiodev = audio_attach_mi(&vaudio_hw_if, sc, self);
 }
 
+static bool
+vaudio_shutdown(device_t self, int flags)
+{
+	struct vaudio_softc *sc = device_private(self);
+
+	if (sc->sc_audiofd != -1)
+		thunk_audio_close(sc->sc_audiofd);
+
+	return true;
+}
+
 static void
 vaudio_intr(void *opaque)
 {

Reply via email to