Commit 3714f4bc authored by Marek Vavruša's avatar Marek Vavruša

daemon/engine: priority prefix ‘<‘ for modules

if the configured modules name is prefixed with ‘<‘ it takes precedence before all others,
e.g. modules = { ‘hints’, ‘<block’ }
means that the ‘hints’ module will be executed in-order (last), and ‘block’ module layer will be called as first in query processing
parent 91a8e2c8
......@@ -434,7 +434,12 @@ int engine_register(struct engine *engine, const char *name)
if (engine == NULL || name == NULL) {
return kr_error(EINVAL);
}
/* Check priority modules */
bool is_priority = false;
if (name[0] == '<') {
is_priority = true;
name += 1;
}
/* Make sure module is unloaded */
(void) engine_unregister(engine, name);
/* Attempt to load binary module */
......@@ -452,11 +457,16 @@ int engine_register(struct engine *engine, const char *name)
free(module);
return ret;
}
if (array_push(engine->modules, module) < 0) {
engine_unload(engine, module);
return kr_error(ENOMEM);
}
/* Push to front if priority module */
if (is_priority) {
struct kr_module **arr = engine->modules.at;
memmove(&arr[1], &arr[0], sizeof(*arr) * (engine->modules.len - 1));
arr[0] = module;
}
/* Register properties */
if (module->props) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment