From 3739efe99a32188e78d167231565328e1c7019c7 Mon Sep 17 00:00:00 2001 From: huangxin Date: Thu, 23 Jun 2022 08:29:48 +0800 Subject: [PATCH] =?UTF-8?q?FIX=20ZNJK-800=20PPPoE=20Session=20memory=20?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E9=87=8A=E6=94=BE=20RCA=20=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E9=87=8A=E6=94=BE=E7=94=A8=E6=88=B7=E4=BB=A5=E5=8F=8A=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=B6=88=E6=81=AF=E5=86=85=E5=AD=98=20SOL=20=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E5=86=85=E5=AD=98=E9=87=8A=E6=94=BE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/CMakeLists.txt | 2 +- srcs/libs/mq/mq_data.c | 18 +++++++++--------- srcs/libs/mq/mq_proto.c | 9 ++++++--- srcs/lwip/src/arch_linux/netif/pcapif.c | 13 +++++++------ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt index 8abbecb..7df5f4e 100644 --- a/srcs/CMakeLists.txt +++ b/srcs/CMakeLists.txt @@ -13,7 +13,7 @@ PKG_SEARCH_MODULE(LIBSSL REQUIRED libssl) PKG_SEARCH_MODULE(LIBCRYPTO REQUIRED libcrypto) SET(COMMON_LIBS ${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS}) -SET(COMMON_LIBS ${COMMON_LIBS} "-ldl -lpthread -lzlog -lm -luv -lzmq -luuid -lconfig -ljemalloc") +SET(COMMON_LIBS ${COMMON_LIBS} "-ldl -lpthread -lzlog -lm -luv -lzmq -luuid -lconfig") INCLUDE_DIRECTORIES(include ./ ./include ./libs/include ./lwip/src/include ./lwip/src/arch_linux/include ${COMMON_INCLUDE}) diff --git a/srcs/libs/mq/mq_data.c b/srcs/libs/mq/mq_data.c index c34d47c..e4685ef 100644 --- a/srcs/libs/mq/mq_data.c +++ b/srcs/libs/mq/mq_data.c @@ -75,13 +75,11 @@ static void free_remove_user(PMQ_DATA_REMOVE_USER p) { } static void free_add_user(PMQ_DATA_ADD_USER p) { - int i, j; + int i; for (i = 0; i < p->infoCount; i++) { - for (j = 0; j < p[i].pInfo->userCount; j++) { - if (p[i].pInfo->pUser) { - free(p[i].pInfo->pUser); - } + if (p[i].pInfo->pUser) { + free(p[i].pInfo->pUser); } } @@ -94,7 +92,7 @@ static void free_mq_data_msg(PMQ_DATA_MSG pMsg) { free((void *)pMsg->entity); } if (pMsg->message) { - free((void *)pMsg->entity); + free((void *)pMsg->message); } if (pMsg->params) { free((void *)pMsg->params); @@ -170,6 +168,8 @@ PMQ_DATA_REMOVE_USER decode_remove_user_msg(const char *pStrJson, PMQ_DATA_REMOV PMQ_DATA_ADD_USER decode_add_user_msg(const char *pStrJson, PMQ_DATA_ADD_USER *pAddUser) { cJSON *pJsonRoot = cJSON_Parse(pStrJson); + dzlog_info("Data Json:\n%s\n", pStrJson); + if (pJsonRoot) { int i; @@ -231,9 +231,9 @@ PMQ_DATA_ADD_USER decode_add_user_msg(const char *pStrJson, PMQ_DATA_ADD_USER *p int j; memset(pCurrent->pUser, 0, sizeof(ADD_USER_USER) * nUser); for (j = 0; j < nUser; j++) { - PADD_USER_USER p = &pCurrent->pUser[j]; - cJSON *pJsonU = cJSON_GetArrayItem(puser, j); - PADD_USER_USER pTmp = j2s_add_user(pJsonU); + PADD_USER_USER p = &pCurrent->pUser[j]; + cJSON *pJsonU = cJSON_GetArrayItem(puser, j); + PADD_USER_USER pTmp = j2s_add_user(pJsonU); if (pTmp) { memcpy(p, pTmp, sizeof(ADD_USER_USER)); diff --git a/srcs/libs/mq/mq_proto.c b/srcs/libs/mq/mq_proto.c index a4657dd..3839049 100644 --- a/srcs/libs/mq/mq_proto.c +++ b/srcs/libs/mq/mq_proto.c @@ -23,6 +23,7 @@ typedef struct { unsigned int len; } JM_BUF, *PJM_BUF; +#if 0 static void print_my_jemalloc_data(void *opaque, const char *str) { PJM_BUF pBuf = (PJM_BUF)opaque; unsigned int len = strlen(str); @@ -35,6 +36,7 @@ static void print_my_jemalloc_data(void *opaque, const char *str) { pBuf->buf = buf; pBuf->len += len; } +#endif static void wait_buf(PJM_BUF pBuf) { do { @@ -59,6 +61,7 @@ const char *on_msg_cmd(const char *pCmd) { if (strcmp(pMsg->cmd, "get") == 0) { if (strcmp(pMsg->key, "mem_info") == 0) { +#if 0 JM_BUF jb; jb.buf = NULL; @@ -66,9 +69,9 @@ const char *on_msg_cmd(const char *pCmd) { malloc_stats_print(print_my_jemalloc_data, &jb, NULL); wait_buf(&jb); - - pRsp = strdup(jb.buf); - dallocx(jb.buf, MALLOCX_TCACHE_NONE); +#endif + pRsp = strdup("Unsupport"); + //dallocx(jb.buf, MALLOCX_TCACHE_NONE); } else if (strcmp(pMsg->key, "cfg_all") == 0) { pRsp = (char *)config_item_dump_fmt(NULL); } else if (strcmp(pMsg->key, "sys_info") == 0) { diff --git a/srcs/lwip/src/arch_linux/netif/pcapif.c b/srcs/lwip/src/arch_linux/netif/pcapif.c index 10814c3..aa6e7d6 100644 --- a/srcs/lwip/src/arch_linux/netif/pcapif.c +++ b/srcs/lwip/src/arch_linux/netif/pcapif.c @@ -330,14 +330,15 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) { if (ebuf != NULL) { if (strlen(pContext->session.data.svrBaseMac) == 0) { if (strlen(pContext->session.data.svrBaseMac) == 0) { + const struct eth_hdr *payloadEth = (const struct eth_hdr *)ebuf->payload; sprintf(pContext->session.data.svrBaseMac, "%02X:%02X:%02X:%02X:%02X:%02X", - eth->src.addr[0], - eth->src.addr[1], - eth->src.addr[2], - eth->src.addr[3], - eth->src.addr[4], - eth->src.addr[5]); + payloadEth->src.addr[0], + payloadEth->src.addr[1], + payloadEth->src.addr[2], + payloadEth->src.addr[3], + payloadEth->src.addr[4], + payloadEth->src.addr[5]); } }