diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmFile.c b/source/dnode/mgmt/mgmt_vnode/src/vmFile.c index 2ae9faf7df..d92440032c 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmFile.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmFile.c @@ -94,6 +94,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t pCfgs = taosMemoryCalloc(vnodesNum, sizeof(SWrapperCfg)); if (pCfgs == NULL) { dError("failed to read %s since out of memory", file); + code = TSDB_CODE_OUT_OF_MEMORY; goto _OVER; } @@ -104,6 +105,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t cJSON *vgId = cJSON_GetObjectItem(vnode, "vgId"); if (!vgId || vgId->type != cJSON_Number) { dError("failed to read %s since vgId not found", file); + taosMemoryFree(pCfgs); goto _OVER; } pCfg->vgId = vgId->valueint; @@ -112,6 +114,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t cJSON *dropped = cJSON_GetObjectItem(vnode, "dropped"); if (!dropped || dropped->type != cJSON_Number) { dError("failed to read %s since dropped not found", file); + taosMemoryFree(pCfgs); goto _OVER; } pCfg->dropped = dropped->valueint; @@ -119,6 +122,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t cJSON *vgVersion = cJSON_GetObjectItem(vnode, "vgVersion"); if (!vgVersion || vgVersion->type != cJSON_Number) { dError("failed to read %s since vgVersion not found", file); + taosMemoryFree(pCfgs); goto _OVER; } pCfg->vgVersion = vgVersion->valueint; @@ -135,7 +139,6 @@ _OVER: if (content != NULL) taosMemoryFree(content); if (root != NULL) cJSON_Delete(root); if (pFile != NULL) taosCloseFile(&pFile); - if (code != 0) taosMemoryFree(pCfgs); terrno = code; return code; @@ -143,8 +146,8 @@ _OVER: int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) { int32_t ret = 0; - char file[PATH_MAX] = {0}; - char realfile[PATH_MAX] = {0}; + char file[PATH_MAX] = {0}; + char realfile[PATH_MAX] = {0}; snprintf(file, sizeof(file), "%s%svnodes.json.bak", pMgmt->path, TD_DIRSEP); snprintf(realfile, sizeof(file), "%s%svnodes.json", pMgmt->path, TD_DIRSEP); diff --git a/source/dnode/mgmt/node_mgmt/src/dmProc.c b/source/dnode/mgmt/node_mgmt/src/dmProc.c index bb71044dd6..ce03d767fe 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmProc.c +++ b/source/dnode/mgmt/node_mgmt/src/dmProc.c @@ -65,6 +65,7 @@ static SProcQueue *dmInitProcQueue(SProc *proc, char *ptr, int32_t size) { } if (proc->ptype & DND_PROC_PARENT) { + memset(ptr, 0, sizeof(SProcQueue)); if (dmInitProcMutex(queue) != 0) { return NULL; } @@ -76,11 +77,11 @@ static SProcQueue *dmInitProcQueue(SProc *proc, char *ptr, int32_t size) { tstrncpy(queue->name, proc->name, sizeof(queue->name)); taosThreadMutexLock(&queue->mutex); - queue->head = 0; - queue->tail = 0; + // queue->head = 0; + // queue->tail = 0; queue->total = bufSize; queue->avail = bufSize; - queue->items = 0; + // queue->items = 0; taosThreadMutexUnlock(&queue->mutex); } diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 94317f7ac8..31d7571363 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -103,7 +103,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) { dnodeObj.port = tsServerPort; tstrncpy(dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN); dnodeObj.fqdn[TSDB_FQDN_LEN - 1] = 0; - snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port); + snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", tsLocalFqdn, tsServerPort); pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode"); if (pTrans == NULL) goto _OVER; @@ -490,7 +490,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC dnodeObj.updateTime = dnodeObj.createdTime; dnodeObj.port = pCreate->port; tstrncpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN); - snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port); + snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", pCreate->fqdn, pCreate->port); pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode"); if (pTrans == NULL) goto _OVER; diff --git a/source/util/src/tuuid.c b/source/util/src/tuuid.c index 8652652024..9d749cc002 100644 --- a/source/util/src/tuuid.c +++ b/source/util/src/tuuid.c @@ -22,6 +22,8 @@ int32_t tGenIdPI32(void) { if (tUUIDHashId == 0) { char uid[65] = {0}; int32_t code = taosGetSystemUUID(uid, sizeof(uid)); + uid[64] = 0; + if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); } else {