From 47970ff8a42e16fdea786ee458163a8141ba6a3a Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 12 May 2022 17:30:57 +0800 Subject: [PATCH] refactor: node mgmt --- source/dnode/mgmt/mgmt_dnode/src/dmInt.c | 6 +----- source/dnode/mgmt/node_mgmt/src/dmExec.c | 2 +- source/dnode/mgmt/node_mgmt/src/dmObj.c | 7 ++++--- source/libs/function/src/tudf.c | 8 ++++---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmInt.c b/source/dnode/mgmt/mgmt_dnode/src/dmInt.c index 7f4b12bcf2..e42c5372ac 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmInt.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmInt.c @@ -104,11 +104,7 @@ static void dmCloseMgmt(SDnodeMgmt *pMgmt) { pMgmt->data.dnodeHash = NULL; } taosWUnLockLatch(&pMgmt->data.latch); - - taosMemoryFreeClear(pMgmt->data.localEp); - taosMemoryFreeClear(pMgmt->data.localFqdn); - taosMemoryFreeClear(pMgmt->data.firstEp); - taosMemoryFreeClear(pMgmt->data.secondEp); + taosMemoryFree(pMgmt); dInfo("dnode-mgmt is cleaned up"); } diff --git a/source/dnode/mgmt/node_mgmt/src/dmExec.c b/source/dnode/mgmt/node_mgmt/src/dmExec.c index 090f441331..b1c7158cd9 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmExec.c +++ b/source/dnode/mgmt/node_mgmt/src/dmExec.c @@ -179,7 +179,7 @@ int32_t dmStartNode(SMgmtWrapper *pWrapper) { } void dmStopNode(SMgmtWrapper *pWrapper) { - if (pWrapper->func.stopFp != NULL) { + if (pWrapper->func.stopFp != NULL && pWrapper->pMgmt != NULL) { (*pWrapper->func.stopFp)(pWrapper->pMgmt); } } diff --git a/source/dnode/mgmt/node_mgmt/src/dmObj.c b/source/dnode/mgmt/node_mgmt/src/dmObj.c index e257004352..acc2b67d71 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmObj.c +++ b/source/dnode/mgmt/node_mgmt/src/dmObj.c @@ -63,15 +63,16 @@ static void dmClearVars(SDnode *pDnode) { taosCloseFile(&pDnode->lockfile); pDnode->lockfile = NULL; } - taosThreadMutexDestroy(&pDnode->mutex); - memset(&pDnode->mutex, 0, sizeof(pDnode->mutex)); - taosMemoryFree(pDnode); taosMemoryFreeClear(pDnode->input.localEp); taosMemoryFreeClear(pDnode->input.localFqdn); taosMemoryFreeClear(pDnode->input.firstEp); taosMemoryFreeClear(pDnode->input.secondEp); taosMemoryFreeClear(pDnode->input.dataDir); + + taosThreadMutexDestroy(&pDnode->mutex); + memset(&pDnode->mutex, 0, sizeof(pDnode->mutex)); + taosMemoryFree(pDnode); dDebug("dnode memory is cleared, data:%p", pDnode); } diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index a577ea200f..07ff785d6c 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -145,7 +145,7 @@ int32_t udfStartUdfd(int32_t startDnodeId) { } SUdfdData *pData = &udfdGlobal; if (pData->startCalled) { - fnInfo("dnode-mgmt start udfd already called"); + fnInfo("dnode start udfd already called"); return 0; } pData->startCalled = true; @@ -163,7 +163,7 @@ int32_t udfStartUdfd(int32_t startDnodeId) { uv_async_send(&pData->stopAsync); uv_thread_join(&pData->thread); pData->needCleanUp = false; - fnInfo("dnode-mgmt udfd cleaned up after spawn err"); + fnInfo("dnode udfd cleaned up after spawn err"); } else { pData->needCleanUp = true; } @@ -172,7 +172,7 @@ int32_t udfStartUdfd(int32_t startDnodeId) { int32_t udfStopUdfd() { SUdfdData *pData = &udfdGlobal; - fnInfo("dnode-mgmt to stop udfd. need cleanup: %d, spawn err: %d", + fnInfo("dnode to stop udfd. need cleanup: %d, spawn err: %d", pData->needCleanUp, pData->spawnErr); if (!pData->needCleanUp || atomic_load_32(&pData->stopCalled)) { return 0; @@ -182,7 +182,7 @@ int32_t udfStopUdfd() { uv_barrier_destroy(&pData->barrier); uv_async_send(&pData->stopAsync); uv_thread_join(&pData->thread); - fnInfo("dnode-mgmt udfd cleaned up"); + fnInfo("dnode udfd cleaned up"); return 0; }