diff options
| author | 刘畅 <[email protected]> | 2023-10-12 08:45:49 +0000 |
|---|---|---|
| committer | 刘畅 <[email protected]> | 2023-10-12 08:45:49 +0000 |
| commit | 32d1ede9d57af683c942d5ab0ecd41b66a1efd56 (patch) | |
| tree | ab111decf365c86d25a3175fa6e0e81174785cca | |
| parent | e4ea2b29c5ca222d793341350b0668d9a50f70d2 (diff) | |
| parent | 3e4154b1fe3377caa2c6b96bcc1fe3c8eabebe54 (diff) | |
Merge branch 'bugfix_memleak_when_queueing_session_full' into 'rel'v1.3.3
fix memory leak when queueing session full
See merge request tango/shaping-engine!45
| -rw-r--r-- | shaping/src/shaper.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp index af03f5b..e0a7c23 100644 --- a/shaping/src/shaper.cpp +++ b/shaping/src/shaper.cpp @@ -750,6 +750,7 @@ static enum shaping_packet_action shaper_pkt_action_decide_no_queue(struct shapi int profile_type = PROFILE_IN_RULE_TYPE_PRIMARY; struct timespec curr_time; unsigned long long enqueue_time; + int enqueue_success = 0; if (meta->is_tcp_pure_ctrl) { shaper_stat_forward_all_rule_inc(ctx->stat, sf, meta->dir, meta->raw_len, ctx->thread_index); @@ -771,7 +772,9 @@ static enum shaping_packet_action shaper_pkt_action_decide_no_queue(struct shapi } FLOW_PUSH: - if (shaper_packet_enqueue(ctx, sf, rx_buff, meta) != 0) { + if (shaper_packet_enqueue(ctx, sf, rx_buff, meta) == 0) { + enqueue_success = 1; + } else { char *addr_str = addr_tuple4_to_str(&sf->tuple4); LOG_ERROR("%s: shaping enqueue packet failed while queue empty for session: %s", LOG_TAG_SHAPING, addr_str); if (addr_str) { @@ -790,6 +793,9 @@ FLOW_PUSH: } DROP: + if (enqueue_success) { + shaper_packet_dequeue(sf); + } shaper_stat_drop_inc(&sf->matched_rule_infos[sf->anchor].primary.stat, meta->dir, ctx->thread_index); sf->anchor = 0; return SHAPING_DROP; |
