perf: 优化session_ctx减少内存占用; 优化global metrics的结构

This commit is contained in:
luwenpeng
2023-11-24 15:17:18 +08:00
parent bda50d79af
commit eedd18183e
12 changed files with 331 additions and 439 deletions

View File

@@ -5,38 +5,6 @@
#include "log.h"
#include "global_metrics.h"
/******************************************************************************
* Struct Metadata
******************************************************************************/
int metadata_isempty(struct metadata *meta)
{
if (meta->write_ref == 0)
{
return 1;
}
else
{
return 0;
}
}
void metadata_copy(struct metadata *dst, struct metadata *src)
{
dst->write_ref++;
dst->session_id = src->session_id;
dst->rehash_index = src->rehash_index;
dst->raw_data = NULL;
dst->raw_len = 0;
dst->l7offset = src->l7offset;
dst->direction = src->direction;
dst->is_ctrl_pkt = src->is_ctrl_pkt;
dst->is_decrypted = src->is_decrypted;
sids_copy(&dst->sids, &src->sids);
route_ctx_copy(&dst->route_ctx, &src->route_ctx);
}
char *memdup(const char *src, int len)
{
if (src == NULL || len == 0)
@@ -72,10 +40,10 @@ void session_ctx_free(struct session_ctx *session_ctx)
session_ctx->session_addr = NULL;
}
if (session_ctx->ctrl_packet_header_data)
if (session_ctx->ctrl_pkt_hdr_ptr)
{
free(session_ctx->ctrl_packet_header_data);
session_ctx->ctrl_packet_header_data = NULL;
free(session_ctx->ctrl_pkt_hdr_ptr);
session_ctx->ctrl_pkt_hdr_ptr = NULL;
}
if (session_ctx->chaining_raw)