From 963d7802266d33919610280fe77bcaaad9b8ea10 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Wed, 5 Jun 2019 16:46:56 +0800 Subject: [PATCH] =?UTF-8?q?pmeinfo=E4=BD=BF=E7=94=A8=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=EF=BC=8C=E8=A7=84=E9=81=BF=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=AF=BC=E8=87=B4=E7=9A=84=E6=97=A0=E6=95=88?= =?UTF-8?q?pme=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/kni_entry.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/entry/src/kni_entry.cpp b/entry/src/kni_entry.cpp index a5770c8..4d671b6 100644 --- a/entry/src/kni_entry.cpp +++ b/entry/src/kni_entry.cpp @@ -36,6 +36,7 @@ struct http_project{ }; struct pme_info{ + int ref_cnt; int protocol; int policy_id; int maat_hit; @@ -145,6 +146,7 @@ struct traceid2pme_search_cb_args{ static struct pme_info* pme_info_new(const struct streaminfo *stream, int thread_seq, void *logger){ struct pme_info* pmeinfo = ALLOC(struct pme_info, 1); + pmeinfo->ref_cnt=1; pmeinfo->tfe_id = g_kni_handle->tfe_count > 0 ? thread_seq % g_kni_handle->tfe_count : -1; uuid_t uu; uuid_generate_random(uu); @@ -274,7 +276,9 @@ error_out: static void pme_info_destroy(struct pme_info *pmeinfo){ void *logger = pmeinfo->logger; - if(pmeinfo != NULL && pmeinfo->sapp_release == 1 && pmeinfo->tfe_release == 1){ + assert(pmeinfo->ref_cnt<=2); + pmeinfo->ref_cnt--; + if(pmeinfo->ref_cnt == 0){ int ret = sendlog_to_kafka(pmeinfo, logger); if(ret < 0){ KNI_LOG_ERROR(logger, "Failed at sendlog to kafka"); @@ -697,6 +701,7 @@ extern "C" char kni_tcpall_entry(const struct streaminfo *stream, void** pme, in case OP_STATE_PENDING: *pme = pmeinfo = pme_info_new(stream, thread_seq, logger); key_size = strnlen(pmeinfo->stream_trace_id, sizeof(pmeinfo->stream_trace_id)); + pmeinfo->ref_cnt++; ret = MESA_htable_add(g_kni_handle->traceid2pme_htable, (const unsigned char *)(pmeinfo->stream_trace_id), key_size, (const void*)pmeinfo); if(ret < 0){