【修改】BugFIX:多个lua脚本中的重名函数可能导致加载错误
This commit is contained in:
@@ -359,6 +359,7 @@ int plugin_env_instance_init(
|
||||
memset(plugin_env, 0, sizeof(struct lua_plugin_env));
|
||||
plugin_env->plugin_env_state = state;
|
||||
plugin_env->plugin_env_plugin_array = NULL;
|
||||
plugin_env->plugin_env_filepath = strdup(specific->config_specific_file);
|
||||
// plugin_env->plugin_env_name = strdup(specific->config_specific_name);
|
||||
/* 从文件中加载load函数, 但此时不调用 */
|
||||
if (script_instance_init_byname(&plugin_env->plugin_env_load_func,
|
||||
@@ -409,6 +410,8 @@ void plugin_env_instance_destory(void *elt)
|
||||
/* 释放已经注册的插件 */
|
||||
if (plugin_env->plugin_env_plugin_array)
|
||||
utarray_free(plugin_env->plugin_env_plugin_array);
|
||||
if (plugin_env->plugin_env_filepath)
|
||||
free(plugin_env->plugin_env_filepath);
|
||||
|
||||
/* 释放插件的加载函数与卸载函数 */
|
||||
script_instance_clean(&plugin_env->plugin_env_load_func);
|
||||
@@ -520,6 +523,8 @@ int thread_state_instance_load(
|
||||
lua_pushlightuserdata(state, plugin_env);
|
||||
lua_setfield(state, -2, PLUGIN_ENV_DEFAULT_KEY);
|
||||
lua_settop(state, 0);
|
||||
luaL_loadfile(state, plugin_env->plugin_env_filepath);
|
||||
lua_pcall(state, 0, 0, 0);
|
||||
|
||||
struct lua_cdata param[2];
|
||||
param[0].cdata_type = DATATYPE_POINTER;
|
||||
|
||||
@@ -64,6 +64,11 @@
|
||||
*
|
||||
* void *lpm_ctx_new_func;
|
||||
* void lpm_ctx_free_func;
|
||||
*
|
||||
* 08-07
|
||||
* BugFix:
|
||||
* 修改struct lua_plugin_env, 其中增加文件路径
|
||||
* 防止在加载过程中由于函数重名导致的加载错误
|
||||
************************************************************************/
|
||||
#ifndef LUA_PLUGIN_MANAGE_INTERNAL_H
|
||||
#define LUA_PLUGIN_MANAGE_INTERNAL_H
|
||||
@@ -278,6 +283,10 @@ struct lua_plugin_env
|
||||
/* 插件申请lua内的全局变量可以保存在该命名空间内, 防止被其他内容覆盖 */
|
||||
// char *plugin_env_name;
|
||||
|
||||
/* bugfix */
|
||||
/* 增加文件路径, 防止在加载过程中出现重名的情况导致加载错误 */
|
||||
char * plugin_env_filepath;
|
||||
|
||||
/* 在lua中保存运行数据的引用ID */
|
||||
int plugin_env_ref_id; /* plugin_env */
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user