FIX ZNJK-800 PPPoE Session memory 重复释放

RCA 重复释放用户以及用户消息内存
SOL 修正内存释放逻辑
This commit is contained in:
huangxin 2022-06-23 08:29:48 +08:00
parent 22f15ab00f
commit 3739efe99a
4 changed files with 23 additions and 19 deletions

View File

@ -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})

View File

@ -75,15 +75,13 @@ 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);
}
}
}
free(p->pInfo);
free(p);
@ -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;

View File

@ -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) {

View File

@ -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]);
}
}