diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmInt.c b/source/dnode/mgmt/mgmt_dnode/src/dmInt.c index 7d927f9fab9c4775a6f66fd8196a1e2db6a83df0..1651552fa42597120d35f88fa2b1e8f12d6d9edf 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmInt.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmInt.c @@ -39,6 +39,29 @@ static int32_t dmOpenMgmt(const SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) return -1; } + pMgmt->data.dnodeId = 0; + pMgmt->data.clusterId = 0; + pMgmt->data.dnodeVer = 0; + pMgmt->data.updateTime = 0; + pMgmt->data.rebootTime = taosGetTimestampMs(); + pMgmt->data.dropped = 0; + pMgmt->data.localEp = strdup(pInput->localEp); + pMgmt->data.localFqdn = strdup(pInput->localFqdn); + pMgmt->data.firstEp = strdup(pInput->firstEp); + pMgmt->data.secondEp = strdup(pInput->secondEp); + pMgmt->data.dataDir = strdup(pInput->dataDir); + pMgmt->data.disks = pInput->disks; + pMgmt->data.numOfDisks = pInput->numOfDisks; + pMgmt->data.supportVnodes = pInput->supportVnodes; + pMgmt->data.serverPort = pInput->serverPort; + taosInitRWLatch(&pMgmt->data.latch); + + if (pMgmt->data.dataDir == NULL || pMgmt->data.localEp == NULL || pMgmt->data.localFqdn == NULL || + pMgmt->data.firstEp == NULL || pMgmt->data.secondEp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + pMgmt->data.dnodeHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); if (pMgmt->data.dnodeHash == NULL) { dError("failed to init dnode hash"); @@ -83,6 +106,12 @@ static void dmCloseMgmt(SDnodeMgmt *pMgmt) { } taosWUnLockLatch(&pMgmt->data.latch); + taosMemoryFreeClear(pMgmt->data.localEp); + taosMemoryFreeClear(pMgmt->data.localFqdn); + taosMemoryFreeClear(pMgmt->data.firstEp); + taosMemoryFreeClear(pMgmt->data.secondEp); + taosMemoryFreeClear(pMgmt->data.dataDir); + dInfo("dnode-mgmt is cleaned up"); } diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 0a612c6d82dd2a76a7b0798688a0707491f5af44..58d22976d3fda6fe9ce53c76b732b2b9cbb8a474 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -93,6 +93,7 @@ typedef struct { int64_t clusterId; const char *localEp; const char *firstEp; + const char *secondEp; const char *localFqdn; uint16_t serverPort; int32_t supportVnodes; @@ -156,32 +157,31 @@ int32_t dmWriteShmFile(const char *path, const char *name, const SShm *pShm); // common define typedef struct { - int32_t dnodeId; - int64_t clusterId; - int64_t dnodeVer; - int64_t updateTime; - int64_t rebootTime; - int32_t unsyncedVgId; - ESyncState vndState; - ESyncState mndState; - bool isMnode; - bool dropped; - SEpSet mnodeEps; - SArray *dnodeEps; - SHashObj *dnodeHash; - SRWLatch latch; - SMsgCb msgCb; - TdFilePtr lockfile; - char *localEp; - char *localFqdn; - char *firstEp; - char *secondEp; - char *dataDir; - SDiskCfg *disks; - int32_t numOfDisks; - int32_t supportVnodes; - uint16_t serverPort; - EDndRunStatus status; + int32_t dnodeId; + int64_t clusterId; + int64_t dnodeVer; + int64_t updateTime; + int64_t rebootTime; + int32_t unsyncedVgId; + ESyncState vndState; + ESyncState mndState; + bool isMnode; + bool dropped; + SEpSet mnodeEps; + SArray *dnodeEps; + SHashObj *dnodeHash; + SRWLatch latch; + SMsgCb msgCb; + TdFilePtr lockfile; + char *localEp; + char *localFqdn; + char *firstEp; + char *secondEp; + char *dataDir; + SDiskCfg *disks; + int32_t numOfDisks; + int32_t supportVnodes; + uint16_t serverPort; } SDnodeData; #ifdef __cplusplus diff --git a/source/dnode/mgmt/node_util/src/dmUtil.c b/source/dnode/mgmt/node_util/src/dmUtil.c index d56346ce672edfe9a9322d860bb44db0fc363a26..e913af203b76063e176da433e5773d400764e7d8 100644 --- a/source/dnode/mgmt/node_util/src/dmUtil.c +++ b/source/dnode/mgmt/node_util/src/dmUtil.c @@ -16,7 +16,6 @@ #define _DEFAULT_SOURCE #include "dmUtil.h" - const char *dmStatStr(EDndRunStatus stype) { switch (stype) { case DND_STAT_INIT: