✨ feat(module manager new): duplicate check mod name after init_cb
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include "stellar/utils.h"
|
#include "stellar/utils.h"
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
UT_icd module_specs_icd = {sizeof(struct module_specific), NULL, NULL, NULL};
|
UT_icd module_specs_icd = {sizeof(struct module_specific), NULL, NULL, NULL};
|
||||||
@@ -87,17 +88,25 @@ struct stellar_module_manager *stellar_module_manager_new_with_toml(toml_table_t
|
|||||||
mod_mgr->schema.max_thread_num=max_thread_num;
|
mod_mgr->schema.max_thread_num=max_thread_num;
|
||||||
mod_mgr->schema.mq_schema=mq_schema;
|
mod_mgr->schema.mq_schema=mq_schema;
|
||||||
|
|
||||||
// TODO: store module specific data in hash
|
// TODO: store module specific in hash
|
||||||
for(int i = 0; i < spec_num; i++)
|
for(int i = 0; i < spec_num; i++)
|
||||||
{
|
{
|
||||||
if (specs[i].on_init_cb != NULL)
|
if (specs[i].on_init_cb != NULL)
|
||||||
{
|
{
|
||||||
//TODO: duplicate check mod_name
|
|
||||||
specs[i].mod=specs[i].on_init_cb(mod_mgr);
|
specs[i].mod=specs[i].on_init_cb(mod_mgr);
|
||||||
|
if(stellar_module_manager_get_module(mod_mgr, specs[i].mod->name)==NULL)
|
||||||
|
{
|
||||||
utarray_push_back(mod_mgr->schema.module_specs_array, &specs[i]);
|
utarray_push_back(mod_mgr->schema.module_specs_array, &specs[i]);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Module %s already exists\n", specs[i].mod->name);
|
||||||
|
if(specs[i].on_exit_cb)specs[i].on_exit_cb(mod_mgr, specs[i].mod);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FREE(specs);
|
FREE(specs);
|
||||||
|
if(mod_mgr->schema.module_specs_array)assert(spec_num==(int)utarray_len(mod_mgr->schema.module_specs_array));
|
||||||
return mod_mgr;
|
return mod_mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user