From dd87e8f7b9738751098c9c799d22906d632e70d7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 12 May 2022 17:12:40 +0800 Subject: [PATCH] refactor: node mgmt --- source/dnode/mgmt/exe/dmMain.c | 2 -- source/dnode/mgmt/node_mgmt/src/dmExec.c | 6 +++++- source/libs/function/inc/fnLog.h | 12 ++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 21776d71f6..ea6845b04f 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -195,8 +195,6 @@ static int32_t dmRunDnode() { int32_t code = dmRun(pDnode); dInfo("start shutting down the service"); - global.pDnode = NULL; - dmClose(pDnode); dmCleanup(); taosCloseLog(); taosCleanupCfg(); diff --git a/source/dnode/mgmt/node_mgmt/src/dmExec.c b/source/dnode/mgmt/node_mgmt/src/dmExec.c index 50d1c8ab46..090f441331 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmExec.c +++ b/source/dnode/mgmt/node_mgmt/src/dmExec.c @@ -203,7 +203,10 @@ void dmCloseNode(SMgmtWrapper *pWrapper) { } taosWLockLatch(&pWrapper->latch); - (*pWrapper->func.closeFp)(pWrapper->pMgmt); + if (pWrapper->pMgmt != NULL) { + (*pWrapper->func.closeFp)(pWrapper->pMgmt); + pWrapper->pMgmt = NULL; + } taosWUnLockLatch(&pWrapper->latch); if (pWrapper->procObj) { @@ -334,6 +337,7 @@ int32_t dmRun(SDnode *pDnode) { dmSetStatus(pDnode, DND_STAT_STOPPED); dmStopNodes(pDnode); dmCloseNodes(pDnode); + dmClose(pDnode); return 0; } else { dmWatchNodes(pDnode); diff --git a/source/libs/function/inc/fnLog.h b/source/libs/function/inc/fnLog.h index f572948907..d85dd02433 100644 --- a/source/libs/function/inc/fnLog.h +++ b/source/libs/function/inc/fnLog.h @@ -10,12 +10,12 @@ extern "C" { #endif -#define fnFatal(...) { if (fnDebugFlag & DEBUG_FATAL) { taosPrintLog("FN FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} -#define fnError(...) { if (fnDebugFlag & DEBUG_ERROR) { taosPrintLog("FN ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} -#define fnWarn(...) { if (fnDebugFlag & DEBUG_WARN) { taosPrintLog("FN WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} -#define fnInfo(...) { if (fnDebugFlag & DEBUG_INFO) { taosPrintLog("FN ", DEBUG_INFO, 255, __VA_ARGS__); }} -#define fnDebug(...) { if (fnDebugFlag & DEBUG_DEBUG) { taosPrintLog("FN ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }} -#define fnTrace(...) { if (fnDebugFlag & DEBUG_TRACE) { taosPrintLog("FN ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }} +#define fnFatal(...) { if (fnDebugFlag & DEBUG_FATAL) { taosPrintLog("FN FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} +#define fnError(...) { if (fnDebugFlag & DEBUG_ERROR) { taosPrintLog("FN ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} +#define fnWarn(...) { if (fnDebugFlag & DEBUG_WARN) { taosPrintLog("FN WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} +#define fnInfo(...) { if (fnDebugFlag & DEBUG_INFO) { taosPrintLog("FN ", DEBUG_INFO, 255, __VA_ARGS__); }} +#define fnDebug(...) { if (fnDebugFlag & DEBUG_DEBUG) { taosPrintLog("FN ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }} +#define fnTrace(...) { if (fnDebugFlag & DEBUG_TRACE) { taosPrintLog("FN ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }} #ifdef __cplusplus }