lua-decision: resolver integration fixes.
authorKrisztian Litkey <krisztian.litkey@intel.com>
Tue, 13 Nov 2012 16:49:03 +0000 (18:49 +0200)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Tue, 13 Nov 2012 17:03:25 +0000 (19:03 +0200)
src/core/lua-decision/element.c
src/core/lua-decision/mdb.c

index 8769f67..8b75a39 100644 (file)
@@ -337,16 +337,16 @@ static void element_install(lua_State *L, mrp_lua_element_t *el)
 
         if (inp->type == SELECT) {
             d  = mrp_lua_select_name(inp->select);
-            p += snprintf(p, e-p, " select_%s", d);
+            p += snprintf(p, e-p, " _select_%s", d);
 
             len = strlen(d) + 7 + 1;
             depends[ndepend++] = dep = alloca(len);
-            sprintf(dep, "select_%s", d);
+            sprintf(dep, "_select_%s", d);
         }
     }
 
     for (i = 0;   i < el->noutput;  i++) {
-        snprintf(target, sizeof(target), "$%s",
+        snprintf(target, sizeof(target), "_table_%s",
                  mrp_lua_table_name(el->outputs[i]));
 
         printf("\%s:%s\n\tupdate(%s)\n\n", target, buf, el->name);
index 2acca39..e7bcd16 100644 (file)
@@ -805,8 +805,8 @@ static void select_install(lua_State *L, mrp_lua_mdb_select_t *sel)
     };
 
     mrp_context_t *ctx;
-    char target[1024], table[1024];
-    const char *depends;
+    char target[1024], table[1024], fact[1024];
+    const char *depends, *table_depends;
 
     MRP_LUA_ENTER;
 
@@ -819,20 +819,32 @@ static void select_install(lua_State *L, mrp_lua_mdb_select_t *sel)
         return;
     }
 
-    printf("\nselect_%s: table_%s\n\tupdate(%s)\n",
-           sel->name, sel->table_name, sel->name);
-
-    snprintf(target, sizeof(target), "select_%s", sel->name);
-    snprintf(table , sizeof(table) , "$%s", sel->table_name);
+    snprintf(target, sizeof(target), "_select_%s", sel->name);
+    snprintf(table , sizeof(table) , "_table_%s" , sel->table_name);
 
     depends = table;
 
+    printf("\n%s: %s\n\tupdate(%s)\n", target, depends, sel->name);
+
+
+
     if (!mrp_resolver_add_prepared_target(ctx->r, target, &depends, 1,
                                           &select_updater, NULL, sel)) {
         printf("Failed to install resolver target for element '%s'.\n",
                sel->name);
     }
 
+    snprintf(fact, sizeof(fact), "$%s", sel->table_name);
+
+    table_depends = fact;
+    if (!mrp_resolver_add_prepared_target(ctx->r, table, &table_depends, 1,
+                                          NULL, NULL, NULL)) {
+        printf("Failed to install table fact dependency for table '%s'.\n",
+               sel->table_name);
+    }
+
+    printf("\n%s: %s\n\tupdate(%s)\n", table, table_depends, sel->name);
+
     MRP_LUA_LEAVE_NOARG;
 }