Print this page
OS-2366 ddi_periodic_add(9F) is entirely rubbish (MORE)

@@ -20,11 +20,11 @@
  */
 
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
- * Copyright 2011 Joyent, Inc.  All rights reserved.
+ * Copyright 2013 Joyent, Inc.  All rights reserved.
  */
 
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/sysmacros.h>

@@ -46,10 +46,11 @@
 #include <sys/debug.h>
 #include <sys/ftrace.h>
 #include <sys/cmn_err.h>
 #include <sys/panic.h>
 #include <sys/ddi.h>
+#include <sys/ddi_periodic.h>
 #include <sys/sunddi.h>
 #include <sys/policy.h>
 #include <sys/zone.h>
 #include <sys/condvar.h>
 #include <sys/thread.h>

@@ -283,10 +284,16 @@
 
                 vfs_unmountall();
                 (void) VFS_MOUNTROOT(rootvfs, ROOT_UNMOUNT);
                 vfs_syncall();
 
+                /*
+                 * Check for (and unregister) any DDI periodic handlers that
+                 * still exist, as they most likely constitute resource leaks:
+                 */
+                ddi_periodic_fini();
+
                 dump_ereports();
                 dump_messages();
 
                 invoke_cb = B_TRUE;