From 772753491b6e0ce7325d2c1ea4dc34c2fe92a7b0 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Fri, 19 Nov 2010 19:43:56 +0000 Subject: [PATCH] Scan the list in reverse order for the shutdown handlers of loaded modules. This way, when there is a dependency between two modules, the handler of the latter probed runs first. This is a similar approach as the modules are unloaded in the same linkerfile. Sponsored by: Sandvine Incorporated Submitted by: Nima Misaghian MFC after: 1 week --- sys/kern/kern_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c index 186986710da7..11fa909698ce 100644 --- a/sys/kern/kern_module.c +++ b/sys/kern/kern_module.c @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_MODULE, "module", "module data structures"); -typedef TAILQ_HEAD(, module) modulelist_t; +typedef TAILQ_HEAD(modulelst, module) modulelist_t; struct module { TAILQ_ENTRY(module) link; /* chain together all modules */ TAILQ_ENTRY(module) flink; /* all modules in a file */ @@ -101,7 +101,7 @@ module_shutdown(void *arg1, int arg2) return; mtx_lock(&Giant); MOD_SLOCK; - TAILQ_FOREACH(mod, &modules, link) + TAILQ_FOREACH_REVERSE(mod, &modules, modulelst, link) MOD_EVENT(mod, MOD_SHUTDOWN); MOD_SUNLOCK; mtx_unlock(&Giant);