【新增】增加新增单个配置的接口

This commit is contained in:
niubinghui
2024-08-19 18:38:22 +08:00
parent 99fbd77198
commit cfe51e7c9a
4 changed files with 60 additions and 4 deletions

View File

@@ -338,6 +338,9 @@ struct lua_plugin_manage_schema *lua_plugin_manage_init(
memset(new_schema->thread_state, 0, thread_count * sizeof(lua_State *));
/* 为将要加载的模块预分配内存 */
new_schema->model_count = specific_count;
/* 如果没有配置, 也应该算是创建成功 */
if ( specific_count == 0 )
return new_schema;
new_schema->model = (struct lua_model *)calloc(specific_count, sizeof(struct lua_model));
if (__glibc_unlikely(!new_schema->model))
{
@@ -389,6 +392,51 @@ struct lua_plugin_manage_schema *lua_plugin_manage_init(
return new_schema;
}
/*
* Function:
* Input:
* Output:
* Return:
* Description:
*/
int lua_plugin_manage_load_one_specific(
struct lua_plugin_manage_schema *schema,
struct lua_config_specific *specific)
{
if (__glibc_unlikely(!schema || !specific))
return -1;
if ( schema->model ) {
schema->model = (struct lua_model *)realloc(schema->model, (schema->model_count + 1) * sizeof(struct lua_model));
schema->model_count += 1;
}
for (int thread_index = 0; thread_index < schema->state_count; ++thread_index)
{
/* 在状态机中加载specific中的配置 */
int load_ret = thread_state_load_specific(schema->thread_state[thread_index],
&schema->model[schema->model_count - 1],
specific);
if (load_ret)
{
LOGERROR("state load specific failed, ret is %d", load_ret);
return -1;
}
/* 调用该模块中的load函数 */
int call_load_ret = thread_state_call_load(schema->thread_state[thread_index],
&schema->model[schema->model_count - 1],
specific,
schema->st);
if (call_load_ret)
{
LOGERROR("call state load function failed, ret is %d", call_load_ret);
return -1;
}
}
return 0;
}
/*
* Function:
* Input: