use safe sys func
This commit is contained in:
parent
66771b41a0
commit
b9d92bd7b7
|
@ -220,62 +220,63 @@ int32_t dmInitVars(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern SMonVloadInfo tsVinfo;
|
extern SMonVloadInfo tsVinfo;
|
||||||
void dmClearVars(SDnode *pDnode) {
|
|
||||||
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
void dmClearVars(SDnode *pDnode) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) {
|
||||||
taosMemoryFreeClear(pWrapper->path);
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype];
|
||||||
(void)taosThreadRwlockDestroy(&pWrapper->lock);
|
taosMemoryFreeClear(pWrapper->path);
|
||||||
|
(void)taosThreadRwlockDestroy(&pWrapper->lock);
|
||||||
}
|
}
|
||||||
if (pDnode->lockfile != NULL) {
|
if (pDnode->lockfile != NULL) {
|
||||||
if (taosUnLockFile(pDnode->lockfile) != 0) {
|
if (taosUnLockFile(pDnode->lockfile) != 0) {
|
||||||
dError("failed to unlock file");
|
dError("failed to unlock file");
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)taosCloseFile(&pDnode->lockfile);
|
(void)taosCloseFile(&pDnode->lockfile);
|
||||||
pDnode->lockfile = NULL;
|
pDnode->lockfile = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeData *pData = &pDnode->data;
|
SDnodeData *pData = &pDnode->data;
|
||||||
(void)taosThreadRwlockWrlock(&pData->lock);
|
(void)taosThreadRwlockWrlock(&pData->lock);
|
||||||
if (pData->oldDnodeEps != NULL) {
|
if (pData->oldDnodeEps != NULL) {
|
||||||
if (dmWriteEps(pData) == 0) {
|
if (dmWriteEps(pData) == 0) {
|
||||||
dmRemoveDnodePairs(pData);
|
dmRemoveDnodePairs(pData);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(pData->oldDnodeEps);
|
taosArrayDestroy(pData->oldDnodeEps);
|
||||||
pData->oldDnodeEps = NULL;
|
pData->oldDnodeEps = NULL;
|
||||||
}
|
}
|
||||||
if (pData->dnodeEps != NULL) {
|
if (pData->dnodeEps != NULL) {
|
||||||
taosArrayDestroy(pData->dnodeEps);
|
taosArrayDestroy(pData->dnodeEps);
|
||||||
pData->dnodeEps = NULL;
|
pData->dnodeEps = NULL;
|
||||||
}
|
}
|
||||||
if (pData->dnodeHash != NULL) {
|
if (pData->dnodeHash != NULL) {
|
||||||
taosHashCleanup(pData->dnodeHash);
|
taosHashCleanup(pData->dnodeHash);
|
||||||
pData->dnodeHash = NULL;
|
pData->dnodeHash = NULL;
|
||||||
}
|
}
|
||||||
(void)taosThreadRwlockUnlock(&pData->lock);
|
(void)taosThreadRwlockUnlock(&pData->lock);
|
||||||
|
|
||||||
(void)taosThreadRwlockDestroy(&pData->lock);
|
(void)taosThreadRwlockDestroy(&pData->lock);
|
||||||
|
|
||||||
dDebug("begin to lock status info when thread exit");
|
dDebug("begin to lock status info when thread exit");
|
||||||
if (taosThreadMutexLock(&pData->statusInfolock) != 0) {
|
if (taosThreadMutexLock(&pData->statusInfolock) != 0) {
|
||||||
dError("failed to lock status info lock");
|
dError("failed to lock status info lock");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tsVinfo.pVloads != NULL) {
|
if (tsVinfo.pVloads != NULL) {
|
||||||
taosArrayDestroy(tsVinfo.pVloads);
|
taosArrayDestroy(tsVinfo.pVloads);
|
||||||
tsVinfo.pVloads = NULL;
|
tsVinfo.pVloads = NULL;
|
||||||
}
|
}
|
||||||
if (taosThreadMutexUnlock(&pData->statusInfolock) != 0) {
|
if (taosThreadMutexUnlock(&pData->statusInfolock) != 0) {
|
||||||
dError("failed to unlock status info lock");
|
dError("failed to unlock status info lock");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (taosThreadMutexDestroy(&pData->statusInfolock) != 0) {
|
if (taosThreadMutexDestroy(&pData->statusInfolock) != 0) {
|
||||||
dError("failed to destroy status info lock");
|
dError("failed to destroy status info lock");
|
||||||
}
|
}
|
||||||
memset(&pData->statusInfolock, 0, sizeof(pData->statusInfolock));
|
memset(&pData->statusInfolock, 0, sizeof(pData->statusInfolock));
|
||||||
|
|
||||||
(void)taosThreadMutexDestroy(&pDnode->mutex);
|
(void)taosThreadMutexDestroy(&pDnode->mutex);
|
||||||
memset(&pDnode->mutex, 0, sizeof(pDnode->mutex));
|
memset(&pDnode->mutex, 0, sizeof(pDnode->mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmSetStatus(SDnode *pDnode, EDndRunStatus status) {
|
void dmSetStatus(SDnode *pDnode, EDndRunStatus status) {
|
||||||
|
|
|
@ -1884,7 +1884,7 @@ static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32
|
||||||
if (strlen(pMCfgReq->value) != 0) goto _err;
|
if (strlen(pMCfgReq->value) != 0) goto _err;
|
||||||
code = taosStr2int32(pMCfgReq->config + optLen + 1, pOutValue);
|
code = taosStr2int32(pMCfgReq->config + optLen + 1, pOutValue);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("dnode:%d, failed to get cfg since code: %s", pMCfgReq->dnodeId, tstrerror(code));
|
mError("dnode:%d, failed to get cfg since %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1892,7 +1892,7 @@ static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32
|
||||||
if (strlen(pMCfgReq->value) == 0) goto _err;
|
if (strlen(pMCfgReq->value) == 0) goto _err;
|
||||||
code = taosStr2int32(pMCfgReq->value, pOutValue);
|
code = taosStr2int32(pMCfgReq->value, pOutValue);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("dnode:%d, failed to get cfg since code: %s", pMCfgReq->dnodeId, tstrerror(code));
|
mError("dnode:%d, failed to get cfg since %s", pMCfgReq->dnodeId, tstrerror(code));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -530,7 +530,7 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
||||||
code = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
code = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
} else {
|
} else {
|
||||||
tstrncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -638,7 +638,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
||||||
opts.source = newBody;
|
opts.source = newBody;
|
||||||
opts.result = newBodyEncrypted;
|
opts.result = newBodyEncrypted;
|
||||||
opts.unitLen = 16;
|
opts.unitLen = 16;
|
||||||
tstrncpy((char *)opts.key, pWal->cfg.encryptKey, ENCRYPT_KEY_LEN);
|
tstrncpy((char *)opts.key, pWal->cfg.encryptKey, ENCRYPT_KEY_LEN + 1);
|
||||||
|
|
||||||
int32_t count = CBC_Encrypt(&opts);
|
int32_t count = CBC_Encrypt(&opts);
|
||||||
|
|
||||||
|
|
|
@ -123,10 +123,8 @@ int32_t taosStr2int64(const char *str, int64_t *val) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
int64_t ret = strtoll(str, &endptr, 10);
|
int64_t ret = strtoll(str, &endptr, 10);
|
||||||
if (errno == ERANGE && (ret == LLONG_MAX || ret == LLONG_MIN)) {
|
if (errno != 0) {
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
} else if (errno == EINVAL && ret == 0) {
|
|
||||||
return TSDB_CODE_INVALID_PARA;
|
|
||||||
} else {
|
} else {
|
||||||
if (endptr == str) {
|
if (endptr == str) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
@ -187,12 +185,11 @@ int32_t taosStr2Uint64(const char *str, uint64_t *val) {
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
uint64_t ret = strtoull(str, &endptr, 10);
|
uint64_t ret = strtoull(str, &endptr, 10);
|
||||||
if (errno == ERANGE && (ret == ULLONG_MAX)) {
|
|
||||||
|
if (errno != 0) {
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
} else if (errno == EINVAL && ret == 0) {
|
|
||||||
return TSDB_CODE_INVALID_PARA;
|
|
||||||
} else {
|
} else {
|
||||||
if (str == endptr) {
|
if (endptr == str) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
*val = ret;
|
*val = ret;
|
||||||
|
|
|
@ -283,30 +283,25 @@ static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value,
|
||||||
tstrncpy(cfg.dir, pItem->str, sizeof(cfg.dir));
|
tstrncpy(cfg.dir, pItem->str, sizeof(cfg.dir));
|
||||||
|
|
||||||
code = taosStr2int32(level, &cfg.level);
|
code = taosStr2int32(level, &cfg.level);
|
||||||
if (code != 0) {
|
TAOS_CHECK_GOTO(code, NULL, _err);
|
||||||
cfg.level = 0;
|
|
||||||
}
|
|
||||||
code = taosStr2int32(primary, &cfg.primary);
|
code = taosStr2int32(primary, &cfg.primary);
|
||||||
if (code != 0) {
|
TAOS_CHECK_GOTO(code, NULL, _err);
|
||||||
cfg.primary = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = taosStr2int8(disable, &cfg.disable);
|
code = taosStr2int8(disable, &cfg.disable);
|
||||||
if (code != 0) {
|
TAOS_CHECK_GOTO(code, NULL, _err);
|
||||||
cfg.disable = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *ret = taosArrayPush(pItem->array, &cfg);
|
void *ret = taosArrayPush(pItem->array, &cfg);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
(void)taosThreadMutexUnlock(&pCfg->lock);
|
code = terrno;
|
||||||
|
TAOS_CHECK_GOTO(code, NULL, _err);
|
||||||
TAOS_RETURN(terrno);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pItem->stype = stype;
|
pItem->stype = stype;
|
||||||
(void)taosThreadMutexUnlock(&pCfg->lock);
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
|
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
|
_err:
|
||||||
|
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||||
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cfgUpdateDebugFlagItem(SConfig *pCfg, const char *name, bool resetArray) {
|
static int32_t cfgUpdateDebugFlagItem(SConfig *pCfg, const char *name, bool resetArray) {
|
||||||
|
|
Loading…
Reference in New Issue