Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Aug 2009 16:54:32 GMT
From:      Julian Elischer <julian@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 167090 for review
Message-ID:  <200908071654.n77GsWsG060566@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=167090

Change 167090 by julian@julian-mac on 2009/08/07 16:54:11

	Better examples for shutdown

Affected files ...

.. //depot/projects/vimage/porting_to_vimage.txt#12 edit

Differences ...

==== //depot/projects/vimage/porting_to_vimage.txt#12 (text+ko) ====

@@ -1,4 +1,4 @@
-July 13 2008
+July 7 2009
 Julian Elischer
 
 ===================
@@ -299,6 +299,22 @@
                 break;
  
         case MOD_SHUTDOWN:
+		/*
+		 * this is called once  but you may want to shut down
+		 * things in each jail.
+		 */
+		{
+			VNET_ITERATOR_DECL(vnet_iter);
+			VNET_LIST_RLOCK();
+			VNET_FOREACH(vnet_iter) {
+				CURVNET_SET(vnet_iter); 
+				mymod_vnet_uninit(NULL);
+				CURVNET_RESTORE();
+			}
+			VNET_LIST_RUNLOCK();
+		}
+		/* you may need to shutdown something global. */
+		mymod_destroy(); 
                 break;
  
         default:
@@ -358,8 +374,6 @@
 
 On system shutdown: [check/fix this ]
       MODEVENT(shutdown)
-      ? VNET_SYSUNINIT called for every jail/vnet
-      ? SYSUNINIT
 
 NOTICE that while the order of the SYSINIT and VNET_SYSINIT is reversed from
 that of SYSUNINIT and VNET_SYSUNINIT, MODEVENTS do not follow
@@ -382,25 +396,7 @@
 (but not the modevent).
 
 Sometimes there is a need to iterate through the vnets.
-The following code should be used as a guide.
-
-	VNET_ITERATOR_DECL(vnet_iter);
-	[...]
- 
-	[...]
-	VNET_LIST_RLOCK();
-	VNET_FOREACH(vnet_iter) {
-		CURVNET_SET(vnet_iter); 
-		[...]
-		do work,
-		including calling code that assumes we have curvnet set.
-		[...]
-		CURVNET_RESTORE();
- 	}
-	VNET_LIST_RUNLOCK();
-	[...]
-}
-
+See the modevent shutdown handler (above) for an example of how to do this.
 
 finally: 
 The command to make a new jail with a new vnet:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908071654.n77GsWsG060566>