TSG-16056 修复deny动作,修复tsg_lua多线程调用问题和tfe编译告警
This commit is contained in:
@@ -151,9 +151,17 @@ static int lua_http_default_headers_init(struct def_lua_http_headers *lua_http_h
|
||||
return 0;
|
||||
}
|
||||
|
||||
int http_lua_profile_for_test(int profile_id, struct elua_script ***elua_ctx)
|
||||
int http_lua_profile_for_test(int profile_id, struct elua_script ***elua_ctx, char **profile_msg, size_t *msg_len, int *timeout)
|
||||
{
|
||||
size_t input_sz;
|
||||
const char* filename="./test_data/http_session.lua";
|
||||
char *input= tfe_read_file(filename, &input_sz);
|
||||
|
||||
*profile_msg=tfe_strdup(input);
|
||||
*msg_len=input_sz;
|
||||
*timeout=1000;
|
||||
*elua_ctx=g_tsg_lua_pattern->elua_ctx;
|
||||
FREE(&input);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -221,6 +229,9 @@ TEST(TSG_LUA_SCRIPT, Lua_TimeOut)
|
||||
clock_gettime(CLOCK_REALTIME, &(end_time));
|
||||
printf("take time %lu(s)\n", end_time.tv_sec - start_time.tv_sec);
|
||||
|
||||
elua_cleanup_script(g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
FREE(&g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
g_tsg_lua_pattern->elua_ctx[thread_id]=NULL;
|
||||
lua_http_session_destory((struct tfe_http_session *)tsg_ctx.session);
|
||||
}
|
||||
|
||||
@@ -244,6 +255,9 @@ TEST(TSG_LUA_SCRIPT, Req_Uri)
|
||||
|
||||
EXPECT_STREQ(tsg_ctx.rewrite_uri,"team");
|
||||
FREE(&tsg_ctx.rewrite_uri);
|
||||
elua_cleanup_script(g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
FREE(&g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
g_tsg_lua_pattern->elua_ctx[thread_id]=NULL;
|
||||
lua_http_session_destory((struct tfe_http_session *)tsg_ctx.session);
|
||||
}
|
||||
|
||||
@@ -272,6 +286,9 @@ TEST(TSG_LUA_SCRIPT, Req_Header)
|
||||
EXPECT_TRUE(x_tg_val!=NULL);
|
||||
EXPECT_STREQ(x_tg_val, "tfe");
|
||||
|
||||
elua_cleanup_script(g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
FREE(&g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
g_tsg_lua_pattern->elua_ctx[thread_id]=NULL;
|
||||
lua_http_session_destory((struct tfe_http_session *)tsg_ctx.session);
|
||||
}
|
||||
|
||||
@@ -296,6 +313,9 @@ TEST(TSG_LUA_SCRIPT, Resp_Header)
|
||||
EXPECT_TRUE(content_type_val!=NULL);
|
||||
EXPECT_STREQ(content_type_val, "utf8");
|
||||
|
||||
elua_cleanup_script(g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
FREE(&g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
g_tsg_lua_pattern->elua_ctx[thread_id]=NULL;
|
||||
lua_http_session_destory((struct tfe_http_session *)tsg_ctx.session);
|
||||
}
|
||||
|
||||
@@ -327,6 +347,9 @@ TEST(TSG_LUA_SCRIPT, Req_Data)
|
||||
evbuffer_free(tsg_ctx.http_body);
|
||||
evbuffer_free(tsg_ctx.http_lua_body);
|
||||
|
||||
elua_cleanup_script(g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
FREE(&g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
g_tsg_lua_pattern->elua_ctx[thread_id]=NULL;
|
||||
lua_http_session_destory((struct tfe_http_session *)tsg_ctx.session);
|
||||
}
|
||||
|
||||
@@ -358,6 +381,9 @@ TEST(TSG_LUA_SCRIPT, Resq_Data)
|
||||
evbuffer_free(tsg_ctx.http_body);
|
||||
evbuffer_free(tsg_ctx.http_lua_body);
|
||||
|
||||
elua_cleanup_script(g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
FREE(&g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
g_tsg_lua_pattern->elua_ctx[thread_id]=NULL;
|
||||
lua_http_session_destory((struct tfe_http_session *)tsg_ctx.session);
|
||||
}
|
||||
|
||||
@@ -398,6 +424,9 @@ TEST(TSG_LUA_SCRIPT, Lua_Http_Session)
|
||||
evbuffer_free(tsg_ctx.http_body);
|
||||
evbuffer_free(tsg_ctx.http_lua_body);
|
||||
|
||||
elua_cleanup_script(g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
FREE(&g_tsg_lua_pattern->elua_ctx[thread_id]);
|
||||
g_tsg_lua_pattern->elua_ctx[thread_id]=NULL;
|
||||
http_lua_ctx_free(lua_script, thread_id, tsg_ctx.elua_ctx);
|
||||
lua_http_session_destory((struct tfe_http_session *)tsg_ctx.session);
|
||||
}
|
||||
@@ -407,21 +436,12 @@ int main(int argc, char ** argv)
|
||||
struct tsg_lua_pattern *tsg_lua_pattern = ALLOC(struct tsg_lua_pattern, 1);
|
||||
TAILQ_INIT(&tsg_lua_pattern->lua_http_head_list.lua_http_field_list);
|
||||
|
||||
int i=0, thread_num=1;
|
||||
int thread_num=1;
|
||||
struct tsg_lua_script *lua_script=ALLOC(struct tsg_lua_script, 1);
|
||||
|
||||
http_lua_handle_create(lua_script, thread_num, "tfe");
|
||||
|
||||
size_t input_sz;
|
||||
const char* filename="./test_data/http_session.lua";
|
||||
char *input= tfe_read_file(filename, &input_sz);
|
||||
|
||||
tsg_lua_pattern->elua_ctx = ALLOC(struct elua_script*, thread_num);
|
||||
for(i=0; i<thread_num; i++)
|
||||
{
|
||||
tsg_lua_pattern->elua_ctx[i]=http_lua_map_cache_script(lua_script->http_lua_handle[i], input, input_sz, 1000);
|
||||
}
|
||||
|
||||
tsg_lua_pattern->lua_script=lua_script;
|
||||
tsg_lua_pattern->thread_num=thread_num;
|
||||
g_tsg_lua_pattern = tsg_lua_pattern;
|
||||
|
||||
Reference in New Issue
Block a user