Kaynağa Gözat

ncd: modules: depend: allow resolving when down

ambrop7 14 yıl önce
ebeveyn
işleme
a1647e91c8
1 değiştirilmiş dosya ile 12 ekleme ve 7 silme
  1. 12 7
      ncd/modules/depend.c

+ 12 - 7
ncd/modules/depend.c

@@ -406,9 +406,11 @@ static void depend_func_clean (void *vo)
 static int depend_func_getvar (void *vo, const char *varname, NCDValue *out)
 {
     struct depend *o = vo;
-    ASSERT(o->p)
-    ASSERT(!o->p->is_queued)
-    ASSERT(!o->p->dying)
+    ASSERT(!o->p || !o->p->is_queued)
+    
+    if (!o->p) {
+        return 0;
+    }
     
     return NCDModuleInst_Backend_GetVar(o->p->i, varname, out);
 }
@@ -416,9 +418,11 @@ static int depend_func_getvar (void *vo, const char *varname, NCDValue *out)
 static NCDModuleInst * depend_func_getobj (void *vo, const char *objname)
 {
     struct depend *o = vo;
-    ASSERT(o->p)
-    ASSERT(!o->p->is_queued)
-    ASSERT(!o->p->dying)
+    ASSERT(!o->p || !o->p->is_queued)
+    
+    if (!o->p) {
+        return NULL;
+    }
     
     return NCDModuleInst_Backend_GetObj(o->p->i, objname);
 }
@@ -438,7 +442,8 @@ static const struct NCDModule modules[] = {
         .func_die = depend_func_die,
         .func_clean = depend_func_clean,
         .func_getvar = depend_func_getvar,
-        .func_getobj = depend_func_getobj
+        .func_getobj = depend_func_getobj,
+        .can_resolve_when_down = 1
     }, {
         .type = NULL
     }