From 1fb5a8c2fd8ff2819f7450924125f5a1795ad54a Mon Sep 17 00:00:00 2001 From: slguan Date: Tue, 14 Apr 2020 00:01:31 +0800 Subject: [PATCH] fix some memory lost --- src/dnode/src/dnodeMClient.c | 1 + src/mnode/src/mgmtSdb.c | 3 ++- src/plugins/http/inc/tgHandle.h | 1 + src/plugins/http/src/httpSystem.c | 4 +++- src/plugins/http/src/tgHandle.c | 5 +++++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dnode/src/dnodeMClient.c b/src/dnode/src/dnodeMClient.c index f9794d040b..5dd015313a 100644 --- a/src/dnode/src/dnodeMClient.c +++ b/src/dnode/src/dnodeMClient.c @@ -249,6 +249,7 @@ static bool dnodeReadMnodeIpList() { PARSE_OVER: free(content); + cJSON_Delete(root); fclose(fp); return ret; } diff --git a/src/mnode/src/mgmtSdb.c b/src/mnode/src/mgmtSdb.c index 5202f8511c..bc0d1b81f2 100644 --- a/src/mnode/src/mgmtSdb.c +++ b/src/mnode/src/mgmtSdb.c @@ -167,6 +167,7 @@ void sdbCleanUp() { sem_destroy(&tsSdbSync->sem); pthread_mutex_destroy(&tsSdbSync->mutex); walClose(tsSdbSync->wal); + free(tsSdbSync); tsSdbSync = NULL; } } @@ -576,5 +577,5 @@ void sdbCloseTable(void *handle) { pthread_mutex_destroy(&pTable->mutex); sdbTrace("table:%s, is closed, numOfTables:%d", pTable->tableName, tsSdbNumOfTables); - tfree(pTable); + free(pTable); } diff --git a/src/plugins/http/inc/tgHandle.h b/src/plugins/http/inc/tgHandle.h index 5b8c49900f..5622694374 100644 --- a/src/plugins/http/inc/tgHandle.h +++ b/src/plugins/http/inc/tgHandle.h @@ -33,6 +33,7 @@ #define TG_PASS_URL_POS 3 void tgInitHandle(HttpServer *pServer); +void tgCleanupHandle(); bool tgProcessRquest(struct HttpContext *pContext); diff --git a/src/plugins/http/src/httpSystem.c b/src/plugins/http/src/httpSystem.c index aa66af9825..46f31a12d6 100644 --- a/src/plugins/http/src/httpSystem.c +++ b/src/plugins/http/src/httpSystem.c @@ -122,12 +122,14 @@ void httpStopSystem() { if (httpServer != NULL) { httpServer->online = false; } + tgCleanupHandle(); } void httpCleanUpSystem() { httpPrint("http service cleanup"); httpStopSystem(); -#if 0 + +#if 1 if (httpServer == NULL) { return; } diff --git a/src/plugins/http/src/tgHandle.c b/src/plugins/http/src/tgHandle.c index c22a7bbdef..2be39743bd 100644 --- a/src/plugins/http/src/tgHandle.c +++ b/src/plugins/http/src/tgHandle.c @@ -116,6 +116,7 @@ void tgFreeSchemas() { } free(tgSchemas.schemas); tgSchemas.size = 0; + tgSchemas.schemas = NULL; } } @@ -290,6 +291,10 @@ void tgInitHandle(HttpServer *pServer) { httpAddMethod(pServer, &tgDecodeMethod); } +void tgCleanupHandle() { + tgFreeSchemas(); +} + bool tgGetUserFromUrl(HttpContext *pContext) { HttpParser *pParser = &pContext->parser; if (pParser->path[TG_USER_URL_POS].len > TSDB_USER_LEN - 1 || pParser->path[TG_USER_URL_POS].len <= 0) { -- GitLab