diff options
| author | fengweihao <[email protected]> | 2023-07-11 16:28:52 +0800 |
|---|---|---|
| committer | fengweihao <[email protected]> | 2023-07-11 16:28:52 +0800 |
| commit | 2451bd795c801ac4bf961a28978fdf8a34dfcbfc (patch) | |
| tree | f1769b096c84c1201e0653ed39e87511aee965bf | |
| parent | 868da4f642615eced38f6c5e9247fcc5be4c67cd (diff) | |
TSG-16056 修复deny动作,修复tsg_lua多线程调用问题和tfe编译告警v4.8.32-20230711
| -rw-r--r-- | common/src/tfe_packet_io.cpp | 3 | ||||
| -rw-r--r-- | common/src/tfe_raw_packet.cpp | 2 | ||||
| -rw-r--r-- | common/src/tfe_utils.cpp | 2 | ||||
| -rw-r--r-- | platform/src/key_keeper.cpp | 2 | ||||
| -rw-r--r-- | platform/src/ssl_service_cache.cpp | 6 | ||||
| -rw-r--r-- | platform/src/ssl_stream.cpp | 2 | ||||
| -rw-r--r-- | plugin/business/chaining-policy/src/chaining_policy.cpp | 1 | ||||
| -rw-r--r-- | plugin/business/doh/src/dns.cpp | 2 | ||||
| -rw-r--r-- | plugin/business/doh/src/doh.cpp | 2 | ||||
| -rw-r--r-- | plugin/business/doh/src/logger.cpp | 2 | ||||
| -rw-r--r-- | plugin/business/tsg-http/include/http_lua.h | 2 | ||||
| -rw-r--r-- | plugin/business/tsg-http/src/http_lua.cpp | 14 | ||||
| -rw-r--r-- | plugin/business/tsg-http/src/tsg_http.cpp | 24 | ||||
| -rw-r--r-- | plugin/business/tsg-http/src/tsg_logger.cpp | 2 | ||||
| -rw-r--r-- | plugin/business/tsg-http/src/tsg_web_cache.cpp | 6 | ||||
| -rw-r--r-- | plugin/business/tsg-http/test/test_http_lua.cpp | 42 | ||||
| -rw-r--r-- | plugin/protocol/http2/src/http2_stream.cpp | 2 |
17 files changed, 73 insertions, 43 deletions
diff --git a/common/src/tfe_packet_io.cpp b/common/src/tfe_packet_io.cpp index af26237..10f741f 100644 --- a/common/src/tfe_packet_io.cpp +++ b/common/src/tfe_packet_io.cpp @@ -981,7 +981,7 @@ static int packet_io_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta, return 0; } -static void packet_io_dump_metadata(struct metadata *meta, void *logger) +__attribute__((unused))static void packet_io_dump_metadata(struct metadata *meta, void *logger) { TFE_LOG_ERROR(logger, "%s: META={session_id: %lu, raw_len: %d, is_e2i_dir: %d, is_ctrl_pkt: %d, l7offset: %d, is_decrypted: %u, sids_num: %d}", LOG_TAG_PKTIO, meta->session_id, meta->raw_len, meta->is_e2i_dir, meta->is_ctrl_pkt, meta->l7offset, meta->is_decrypted, meta->sids.num); } @@ -1196,7 +1196,6 @@ static int handle_session_opening(struct metadata *meta, struct ctrl_pkt_parser uint8_t hit_no_intercept = 0; uint16_t out_size = 0; char stream_traceid[24] = {0}; - char reason_hit_no_intercept[] = "Hit No Intercept"; char reason_invalid_intercept_param[] = "Invalid Intercept Param"; char reason_invalid_tcp_policy_param[] = "Invalid tcp policy Param"; char reason_underlying_stream_error[] = "Underlying Stream Error"; diff --git a/common/src/tfe_raw_packet.cpp b/common/src/tfe_raw_packet.cpp index 838cd73..9efada2 100644 --- a/common/src/tfe_raw_packet.cpp +++ b/common/src/tfe_raw_packet.cpp @@ -889,7 +889,7 @@ static const void *parse_vxlan(struct raw_pkt_parser *handler, const void *data, return data; } - struct vxlan_hdr *vxlan_hdr = (struct vxlan_hdr *)data; + //struct vxlan_hdr *vxlan_hdr = (struct vxlan_hdr *)data; uint16_t hdr_len = sizeof(struct vxlan_hdr); const void *data_next_layer = (const char *)data + hdr_len; size_t data_next_length = length - hdr_len; diff --git a/common/src/tfe_utils.cpp b/common/src/tfe_utils.cpp index d5c85c2..89722c9 100644 --- a/common/src/tfe_utils.cpp +++ b/common/src/tfe_utils.cpp @@ -276,7 +276,7 @@ void route_ctx_copy(struct route_ctx *dst, struct route_ctx *src) #define CHECKSUM_CARRY(x) (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff)) -static int checksum(u_int16_t *addr, int len) +__attribute__((unused)) static int checksum(u_int16_t *addr, int len) { int sum = 0; int nleft = len; diff --git a/platform/src/key_keeper.cpp b/platform/src/key_keeper.cpp index a48854b..cd622fc 100644 --- a/platform/src/key_keeper.cpp +++ b/platform/src/key_keeper.cpp @@ -740,7 +740,7 @@ void key_keeper_async_ask(struct future * f, struct key_keeper * keeper, const c pthread_rwlock_rdlock(&(keeper->rwlock)); MESA_htable_search_cb(keeper->cert_cache, (const unsigned char*)(ctx->key), ctx->key_len, keyring_local_cache_query_cb, p, &cb_rtn); pthread_rwlock_unlock(&(keeper->rwlock)); - TFE_LOG_DEBUG(keeper->logger, "Key keeper cache search key: %s, found: %d (0:KEYRING_EXSITED, -1:KEYRING_NOT_EXSITED, -2:KEYRING_EXPIRE)", tmp, cb_rtn); + TFE_LOG_DEBUG(keeper->logger, "Key keeper cache search key: %s, found: %ld (0:KEYRING_EXSITED, -1:KEYRING_NOT_EXSITED, -2:KEYRING_EXPIRE)", tmp, cb_rtn); free(tmp); if(cb_rtn == KEYRING_EXSITED) { diff --git a/platform/src/ssl_service_cache.cpp b/platform/src/ssl_service_cache.cpp index 3a53c20..0561f43 100644 --- a/platform/src/ssl_service_cache.cpp +++ b/platform/src/ssl_service_cache.cpp @@ -437,14 +437,14 @@ int ssl_service_cache_read(struct ssl_service_cache *svc_cache, const struct ssl temp_key_sz = ssl_svc_client_st_mk_key(&addr_info, chello, tcp_stream, temp_key, sizeof(temp_key)); hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key; MESA_htable_search_cb(svc_cache->cli_st_hash, hash_key, (unsigned int) hash_key_sz, cli_st_read_cb, result, &cli_st_cb_ret); - TFE_LOG_DEBUG(g_default_logger, "client table, hash:%s, found:%d, sni:%s, addr:%s, mutual:%d, pinning:%d, err:%d", + TFE_LOG_DEBUG(g_default_logger, "client table, hash:%s, found:%ld, sni:%s, addr:%s, mutual:%d, pinning:%d, err:%d", hash_key, cli_st_cb_ret, chello->sni, tcp_stream->str_stream_info, result->is_mutual_auth, result->cli_pinning_status, result->has_protocol_errors); memset(hash_key, 0, sizeof(hash_key)); temp_key_sz = ssl_svc_server_st_mk_key(&addr_info, chello, tcp_stream, temp_key, sizeof(temp_key)); hash_key_sz = tfe_hexdump(hash_key, (unsigned char *)temp_key, temp_key_sz) - hash_key; MESA_htable_search_cb(svc_cache->srv_st_hash, hash_key, (unsigned int) hash_key_sz, srv_st_read_cb, result, &svr_st_cb_ret); - TFE_LOG_DEBUG(g_default_logger, "server table, hash:%s, found:%d, sni:%s, addr:%s, ct:%d, ev:%d", + TFE_LOG_DEBUG(g_default_logger, "server table, hash:%s, found:%ld, sni:%s, addr:%s, ct:%d, ev:%d", hash_key, svr_st_cb_ret, chello->sni, tcp_stream->str_stream_info, result->is_ct, result->is_ev); char ja3_hash[64] = {0}; @@ -463,7 +463,7 @@ int ssl_service_cache_read(struct ssl_service_cache *svc_cache, const struct ssl } } } - TFE_LOG_DEBUG(g_default_logger, "app table, hash:%s, found:%d, sni:%s, addr:%s, ja3_pinning_status:%d", + TFE_LOG_DEBUG(g_default_logger, "app table, hash:%s, found:%ld, sni:%s, addr:%s, ja3_pinning_status:%d", ja3_hash, app_st_cb_ret, chello->sni, tcp_stream->str_stream_info, result->ja3_pinning_status); free(addr_str); diff --git a/platform/src/ssl_stream.cpp b/platform/src/ssl_stream.cpp index efffae2..60db7cb 100644 --- a/platform/src/ssl_stream.cpp +++ b/platform/src/ssl_stream.cpp @@ -2076,7 +2076,7 @@ void ssl_stream_free(struct ssl_stream * s_stream, struct event_base * evbase, s size_t rx_offset_this_time = 0; tfe_stream_info_get(s_stream->tcp_stream, INFO_FROM_UPSTREAM_RX_OFFSET, &rx_offset_this_time, sizeof(rx_offset_this_time)); const char * sni = (s_stream->up_parts.client_hello && s_stream->up_parts.client_hello->sni) ? s_stream->up_parts.client_hello->sni : "null"; - TFE_LOG_DEBUG(g_default_logger, "ssl up stream close, rx_offset:%d, sni:%s", rx_offset_this_time, sni); + TFE_LOG_DEBUG(g_default_logger, "ssl up stream close, rx_offset:%zu, sni:%s", rx_offset_this_time, sni); } if(errno) diff --git a/plugin/business/chaining-policy/src/chaining_policy.cpp b/plugin/business/chaining-policy/src/chaining_policy.cpp index 9d9cf02..ffd3852 100644 --- a/plugin/business/chaining-policy/src/chaining_policy.cpp +++ b/plugin/business/chaining-policy/src/chaining_policy.cpp @@ -33,7 +33,6 @@ static void chaining_param_new_cb(const char *table_name, int table_id, const ch { cJSON *json = NULL; cJSON *item = NULL; - cJSON *element = NULL; size_t user_region_offset = 0; size_t user_region_len = 0; struct chaining_param *param = NULL; diff --git a/plugin/business/doh/src/dns.cpp b/plugin/business/doh/src/dns.cpp index 5db09f7..b29c42e 100644 --- a/plugin/business/doh/src/dns.cpp +++ b/plugin/business/doh/src/dns.cpp @@ -199,7 +199,7 @@ static void get_rr_type_nsec3(char **ptr, nsec3_t *nsec3, char *end) } // unused -static int get_rr_signer(u_char **ptr, u_char *buf, int buflen, char *end) +__attribute__((unused))static int get_rr_signer(u_char **ptr, u_char *buf, int buflen, char *end) { u_char *p = NULL; int len = 0, i = 0; diff --git a/plugin/business/doh/src/doh.cpp b/plugin/business/doh/src/doh.cpp index bba3aab..500f577 100644 --- a/plugin/business/doh/src/doh.cpp +++ b/plugin/business/doh/src/doh.cpp @@ -915,9 +915,9 @@ void doh_on_end(const struct tfe_stream *stream, const struct tfe_http_session * int ret = doh_send_log(g_doh_conf, session, stream, ctx); if (ret > 0) { - doh_send_metric_log(stream, ctx, thread_id); ATOMIC_ADD(&(g_doh_conf->stat_val[STAT_LOG_NUM]), ret); } + doh_send_metric_log(stream, ctx, thread_id); } doh_ctx_free(ctx); diff --git a/plugin/business/doh/src/logger.cpp b/plugin/business/doh/src/logger.cpp index 6cb1d6b..88526de 100644 --- a/plugin/business/doh/src/logger.cpp +++ b/plugin/business/doh/src/logger.cpp @@ -451,7 +451,7 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c for (size_t i = 0; i < result_num; i++) { - TFE_LOG_DEBUG(handle->local_logger, "URL: %s, policy_id: %d, service: %d, do_log:%d", + TFE_LOG_DEBUG(handle->local_logger, "URL: %s, policy_id: %lld, service: %d, do_log:%d", http->req->req_spec.url, result[i].config_id, result[i].service_id, diff --git a/plugin/business/tsg-http/include/http_lua.h b/plugin/business/tsg-http/include/http_lua.h index 060fcec..545166e 100644 --- a/plugin/business/tsg-http/include/http_lua.h +++ b/plugin/business/tsg-http/include/http_lua.h @@ -11,7 +11,7 @@ struct tsg_lua_script { int lua_is_cache; struct elua_vm **http_lua_handle; - int (*http_lua_profile)(int profile_id, struct elua_script ***elua_ctx); + int (*http_lua_profile)(int profile_id, struct elua_script ***elua_ctx, char **profile_msg, size_t *msg_len, int *timeout); }; struct tsg_script_ctx diff --git a/plugin/business/tsg-http/src/http_lua.cpp b/plugin/business/tsg-http/src/http_lua.cpp index 05cbb1f..aba6204 100644 --- a/plugin/business/tsg-http/src/http_lua.cpp +++ b/plugin/business/tsg-http/src/http_lua.cpp @@ -824,14 +824,21 @@ finish: size_t execute_lua_script_rule(struct tsg_lua_script *lua_script, int profile_id, struct elua_context *elua_ctx, unsigned int thread_id, void *user_data) { int ret=0; + char *profile_msg=NULL; + size_t msg_len=0; int timeout=0; struct elua_script **escript=NULL; - ret=lua_script->http_lua_profile(profile_id, &escript); + ret=lua_script->http_lua_profile(profile_id, &escript, &profile_msg, &msg_len, &timeout); if(ret<0) { return ret; } + if(*escript == NULL) + { + escript[thread_id]=http_lua_map_cache_script(lua_script->http_lua_handle[thread_id], profile_msg, msg_len, timeout); + } + const char *input="tfe"; size_t input_len=strlen(input); @@ -844,6 +851,11 @@ size_t execute_lua_script_rule(struct tsg_lua_script *lua_script, int profile_id TFE_LOG_ERROR(tsg_ctx->local_logger, "policy_id:%d, profile_id:%d, error_code:%d, error: %s", tsg_ctx->config_id, tsg_ctx->profile_id, ret, elua_get_last_error_string(lua_script->http_lua_handle[thread_id])); } } + if(profile_msg != NULL) + { + FREE(&profile_msg); + } + return ret; } diff --git a/plugin/business/tsg-http/src/tsg_http.cpp b/plugin/business/tsg-http/src/tsg_http.cpp index dbbcd94..4d8a287 100644 --- a/plugin/business/tsg-http/src/tsg_http.cpp +++ b/plugin/business/tsg-http/src/tsg_http.cpp @@ -683,7 +683,6 @@ void policy_action_param_new(const char *table_name, int table_id, const char* k } *ad=param; TFE_LOG_INFO(g_proxy_rt->local_logger, "Add ctrl policy: %lld", config_id); -error_out: cJSON_Delete(json); return; } @@ -890,15 +889,8 @@ void ma_lua_profile_table_new_cb(const char *table_name, int table_id, const cha return; } - int i=0, thread_num = g_proxy_rt->thread_num; - struct tsg_lua_script *lua_script = &(g_proxy_rt->lua_script); - + int thread_num = g_proxy_rt->thread_num; ply_profile->escript_ctx = ALLOC(struct elua_script *, thread_num); - for(i=0; i<thread_num; i++) - { - ply_profile->escript_ctx[i]=http_lua_map_cache_script(lua_script->http_lua_handle[i], ply_profile->profile_msg, ply_profile->msg_len, timeout); - } - TFE_LOG_INFO(g_proxy_rt->local_logger, "Policy table add success %d", profile_id); *ad = ply_profile; @@ -933,7 +925,12 @@ void ma_profile_table_free_cb(int table_id, void **ad, long argl, void *argp) int i=0; for(i=0; i<g_proxy_rt->thread_num; i++) { - elua_cleanup_script(ply_obj->escript_ctx[i]); + if(ply_obj->escript_ctx[i]) + { + elua_cleanup_script(ply_obj->escript_ctx[i]); + FREE(&ply_obj->escript_ctx[i]); + ply_obj->escript_ctx[i]=NULL; + } } free(ply_obj->escript_ctx); ply_obj->escript_ctx=NULL; @@ -1686,7 +1683,7 @@ static int http_enforcement_ratio(float enforcement_ratio) return 0; } -int http_lua_profile(int profile_id, struct elua_script ***elua_ctx) +int http_lua_profile(int profile_id, struct elua_script ***elua_ctx, char **profile_msg, size_t *msg_len, int *timeout) { int ret = 0; @@ -1698,6 +1695,9 @@ int http_lua_profile(int profile_id, struct elua_script ***elua_ctx) } *elua_ctx=lua_profile->escript_ctx; + *profile_msg=tfe_strdup(lua_profile->profile_msg); + *msg_len=lua_profile->msg_len; + *timeout=lua_profile->timeout; ma_profile_table_free(lua_profile); lua_profile = NULL; return ret; @@ -2178,7 +2178,7 @@ static void http_block(const struct tfe_stream * stream, const struct tfe_http_s int profile_id = param->profile_id; char *message = param->message; - if (resp_code <= 0 || profile_id < 0){ + if (profile_id < 0){ TFE_LOG_ERROR(g_proxy_rt->local_logger, "Invalid block rule %lld", ctx->enforce_rules[0].config_id); ctx->action = PX_ACTION_NONE; return; diff --git a/plugin/business/tsg-http/src/tsg_logger.cpp b/plugin/business/tsg-http/src/tsg_logger.cpp index b438d3a..55b098d 100644 --- a/plugin/business/tsg-http/src/tsg_logger.cpp +++ b/plugin/business/tsg-http/src/tsg_logger.cpp @@ -346,7 +346,7 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg) for(size_t i=0; i<log_msg->result_num; i++) { - TFE_LOG_DEBUG(handle->local_logger, "URL: %s, policy_id: %d, service: %d, do_log:%d", + TFE_LOG_DEBUG(handle->local_logger, "URL: %s, policy_id: %lld, service: %d, do_log:%d", http->req->req_spec.url, log_msg->result[i].config_id, log_msg->result[i].service_id, diff --git a/plugin/business/tsg-http/src/tsg_web_cache.cpp b/plugin/business/tsg-http/src/tsg_web_cache.cpp index 0011ad9..1f63d55 100644 --- a/plugin/business/tsg-http/src/tsg_web_cache.cpp +++ b/plugin/business/tsg-http/src/tsg_web_cache.cpp @@ -1247,14 +1247,14 @@ void cache_write_future_ctx_free(struct cache_write_future_ctx* ctx) static void wrap_cache_write_on_succ(future_result_t * result, void * user) { struct cache_write_future_ctx* ctx=(struct cache_write_future_ctx*)user; - TFE_LOG_DEBUG(ctx->ref_handle->logger, "cache upload success: %s path: %s elapse: %d", + TFE_LOG_DEBUG(ctx->ref_handle->logger, "cache upload success: %s path: %s elapse: %ld", ctx->url, ctx->upload_path, time(NULL)-ctx->start); cache_write_future_ctx_free(ctx); } static void wrap_cache_write_on_fail(enum e_future_error err, const char * what, void * user) { struct cache_write_future_ctx* ctx=(struct cache_write_future_ctx*)user; - TFE_LOG_DEBUG(ctx->ref_handle->logger, "cache upload failed: %s %s lapse: %d", ctx->url, what, time(NULL)-ctx->start); + TFE_LOG_DEBUG(ctx->ref_handle->logger, "cache upload failed: %s %s lapse: %ld", ctx->url, what, time(NULL)-ctx->start); ATOMIC_INC(&(ctx->ref_handle->stat_val[STAT_CACHE_WRITE_ERR])); cache_write_future_ctx_free(ctx); } @@ -1316,7 +1316,7 @@ struct cache_write_context* web_cache_write_start(struct cache_handle* handle, u ) { ATOMIC_INC(&(handle->stat_val[STAT_CACHE_WRITE_FORBIDEN])); - TFE_LOG_DEBUG(handle->logger, "cache write forbiden: %s, bypass:%d, cont_len:%lld, has_cookie:%d, is_html:%d", + TFE_LOG_DEBUG(handle->logger, "cache write forbiden: %s, bypass:%d, cont_len:%zu, has_cookie:%d, is_html:%d", session->req->req_spec.url, _mid->shall_bypass, content_len, diff --git a/plugin/business/tsg-http/test/test_http_lua.cpp b/plugin/business/tsg-http/test/test_http_lua.cpp index 330b5bf..bf99e46 100644 --- a/plugin/business/tsg-http/test/test_http_lua.cpp +++ b/plugin/business/tsg-http/test/test_http_lua.cpp @@ -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; diff --git a/plugin/protocol/http2/src/http2_stream.cpp b/plugin/protocol/http2/src/http2_stream.cpp index c5ea3b3..c96e0fa 100644 --- a/plugin/protocol/http2/src/http2_stream.cpp +++ b/plugin/protocol/http2/src/http2_stream.cpp @@ -1099,7 +1099,7 @@ static int http2_submit_frame_goaway(struct tfe_h2_stream *connection, const ngh } finish: TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit goaway, stream_id:%d, action:%d, errod_code:%d, data:%.*s", connection->tf_stream->str_stream_info, - dir, goaway->last_stream_id, connection->stream_action, goaway->error_code, goaway->opaque_data_len, goaway->opaque_data); + dir, goaway->last_stream_id, connection->stream_action, goaway->error_code, (int)goaway->opaque_data_len, goaway->opaque_data); connection->goaway = 1; connection->stream_action = stream_action; return 0; |
