Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Don't loop eternal if init of a builtin module fails.



details:   https://anonhg.NetBSD.org/src/rev/eff1bdaf4b3e
branches:  trunk
changeset: 754013:eff1bdaf4b3e
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Apr 16 11:51:23 2010 +0000

description:
Don't loop eternal if init of a builtin module fails.

diffstat:

 sys/kern/kern_module.c |  23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diffs (58 lines):

diff -r 71f8153b0f08 -r eff1bdaf4b3e sys/kern/kern_module.c
--- a/sys/kern/kern_module.c    Fri Apr 16 11:44:44 2010 +0000
+++ b/sys/kern/kern_module.c    Fri Apr 16 11:51:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_module.c,v 1.62 2010/03/18 18:25:45 pooka Exp $   */
+/*     $NetBSD: kern_module.c,v 1.63 2010/04/16 11:51:23 pooka Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.62 2010/03/18 18:25:45 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.63 2010/04/16 11:51:23 pooka Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -395,6 +395,7 @@
 void
 module_init_class(modclass_t class)
 {
+       TAILQ_HEAD(, module) bi_fail = TAILQ_HEAD_INITIALIZER(bi_fail);
        module_t *mod;
        modinfo_t *mi;
 
@@ -408,7 +409,16 @@
                        mi = mod->mod_info;
                        if (class != MODULE_CLASS_ANY && class != mi->mi_class)
                                continue;
-                       (void)module_do_builtin(mi->mi_name, NULL);
+                       /*
+                        * If initializing a builtin module fails, don't try
+                        * to load it again.  But keep it around and queue it
+                        * on the disabled list after we're done with module
+                        * init.
+                        */
+                       if (module_do_builtin(mi->mi_name, NULL) != 0) {
+                               TAILQ_REMOVE(&module_builtins, mod, mod_chain);
+                               TAILQ_INSERT_TAIL(&bi_fail, mod, mod_chain);
+                       }
                        break;
                }
        } while (mod != NULL);
@@ -427,6 +437,13 @@
                        break;
                }
        } while (mod != NULL);
+
+       /* failed builtin modules remain disabled */
+       while ((mod = TAILQ_FIRST(&bi_fail)) != NULL) {
+               TAILQ_REMOVE(&bi_fail, mod, mod_chain);
+               TAILQ_INSERT_TAIL(&module_builtins, mod, mod_chain);
+       }
+
        mutex_exit(&module_lock);
 }
 



Home | Main Index | Thread Index | Old Index