refactor error code
This commit is contained in:
parent
690c6e1cf1
commit
26663153b5
|
@ -135,8 +135,7 @@ int32_t dmReadEps(SDnodeData *pData) {
|
|||
if (strlen(tsEncryptAlgorithm) > 0) {
|
||||
if (strcmp(tsEncryptAlgorithm, "sm4") == 0) {
|
||||
pData->encryptAlgorigthm = DND_CA_SM4;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPT_CONFIG;
|
||||
dError("invalid tsEncryptAlgorithm:%s", tsEncryptAlgorithm);
|
||||
goto _OVER;
|
||||
|
@ -316,33 +315,30 @@ int32_t dmWriteEps(SDnodeData *pData) {
|
|||
snprintf(file, sizeof(file), "%s%sdnode%sdnode.json.bak", tsDataDir, TD_DIRSEP, TD_DIRSEP);
|
||||
snprintf(realfile, sizeof(realfile), "%s%sdnode%sdnode.json", tsDataDir, TD_DIRSEP, TD_DIRSEP);
|
||||
|
||||
|
||||
// if ((code == dmInitDndInfo(pData)) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(code = dmInitDndInfo(pData), NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(dmInitDndInfo(pData), NULL, _OVER);
|
||||
|
||||
pJson = tjsonCreateObject();
|
||||
if (pJson == NULL)
|
||||
TAOS_CHECK_GOTO(code = TSDB_CODE_OUT_OF_MEMORY, NULL, _OVER);
|
||||
if (pJson == NULL) TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _OVER);
|
||||
|
||||
pData->engineVer = tsVersion;
|
||||
|
||||
TAOS_CHECK_GOTO(code = dmEncodeEps(pJson, pData), NULL, _OVER);//dmEncodeEps(pJson, pData) != 0) goto _OVER;
|
||||
TAOS_CHECK_GOTO(dmEncodeEps(pJson, pData), NULL, _OVER); // dmEncodeEps(pJson, pData) != 0) goto _OVER;
|
||||
|
||||
buffer = tjsonToString(pJson);
|
||||
if (buffer == NULL) {
|
||||
TAOS_CHECK_GOTO(code = TSDB_CODE_OUT_OF_MEMORY, NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _OVER);
|
||||
}
|
||||
code = 0;
|
||||
|
||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) goto _OVER;
|
||||
if (pFile == NULL) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
||||
|
||||
int32_t len = strlen(buffer);
|
||||
if (taosWriteFile(pFile, buffer, len) <= 0) goto _OVER;
|
||||
if (taosFsyncFile(pFile) < 0) goto _OVER;
|
||||
if (taosWriteFile(pFile, buffer, len) <= 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
||||
if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
||||
|
||||
taosCloseFile(&pFile);
|
||||
if (taosRenameFile(file, realfile) != 0) goto _OVER;
|
||||
if (taosRenameFile(file, realfile) != 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
||||
|
||||
code = 0;
|
||||
pData->updateTime = taosGetTimestampMs();
|
||||
|
@ -355,7 +351,6 @@ _OVER:
|
|||
if (pFile != NULL) taosCloseFile(&pFile);
|
||||
|
||||
if (code != 0) {
|
||||
// code = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to write dnode file:%s since %s, dnodeVer:%" PRId64, realfile, tstrerror(code), pData->dnodeVer);
|
||||
}
|
||||
return code;
|
||||
|
|
Loading…
Reference in New Issue