void unused return value
This commit is contained in:
parent
10531c0b19
commit
e0e467086c
|
@ -115,8 +115,8 @@ typedef SOCKET EpollFd;
|
|||
#define __PDP_ENDIAN PDP_ENDIAN
|
||||
#endif
|
||||
|
||||
typedef int32_t SocketFd;
|
||||
typedef SocketFd EpollFd;
|
||||
typedef int32_t SocketFd;
|
||||
// typedef SocketFd EpollFd;
|
||||
|
||||
typedef struct TdSocketServer *TdSocketServerPtr;
|
||||
typedef struct TdSocket *TdSocketPtr;
|
||||
|
|
|
@ -114,11 +114,11 @@ static inline SWalFileInfo* walGetCurFileInfo(SWal* pWal) {
|
|||
}
|
||||
|
||||
static inline void walBuildLogName(SWal* pWal, int64_t fileFirstVer, char* buf) {
|
||||
sprintf(buf, "%s/%020" PRId64 "." WAL_LOG_SUFFIX, pWal->path, fileFirstVer);
|
||||
TAOS_UNUSED(sprintf(buf, "%s/%020" PRId64 "." WAL_LOG_SUFFIX, pWal->path, fileFirstVer));
|
||||
}
|
||||
|
||||
static inline void walBuildIdxName(SWal* pWal, int64_t fileFirstVer, char* buf) {
|
||||
sprintf(buf, "%s/%020" PRId64 "." WAL_INDEX_SUFFIX, pWal->path, fileFirstVer);
|
||||
TAOS_UNUSED(sprintf(buf, "%s/%020" PRId64 "." WAL_INDEX_SUFFIX, pWal->path, fileFirstVer));
|
||||
}
|
||||
|
||||
static inline int walValidHeadCksum(SWalCkHead* pHead) {
|
||||
|
|
|
@ -57,7 +57,7 @@ static FORCE_INLINE int32_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx, in
|
|||
walBuildLogName(pWal, pFileInfo->firstVer, fnameStr);
|
||||
|
||||
int64_t fileSize = 0;
|
||||
taosStatFile(fnameStr, &fileSize, NULL, NULL);
|
||||
(void)taosStatFile(fnameStr, &fileSize, NULL, NULL);
|
||||
|
||||
TdFilePtr pFile = taosOpenFile(fnameStr, TD_FILE_READ | TD_FILE_WRITE);
|
||||
if (pFile == NULL) {
|
||||
|
@ -362,7 +362,7 @@ static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) {
|
|||
walBuildIdxName(pWal, pFileInfo->firstVer, fnameStr);
|
||||
|
||||
int64_t fileSize = 0;
|
||||
taosStatFile(fnameStr, &fileSize, NULL, NULL);
|
||||
(void)taosStatFile(fnameStr, &fileSize, NULL, NULL);
|
||||
int64_t records = TMAX(0, pFileInfo->lastVer - pFileInfo->firstVer + 1);
|
||||
int64_t lastEndOffset = records * sizeof(SWalIdxEntry);
|
||||
|
||||
|
@ -378,8 +378,8 @@ static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) {
|
|||
wInfo("vgId:%d, trim idx file. file: %s, size: %" PRId64 ", offset: %" PRId64, pWal->cfg.vgId, fnameStr, fileSize,
|
||||
lastEndOffset);
|
||||
|
||||
taosFtruncateFile(pFile, lastEndOffset);
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosFtruncateFile(pFile, lastEndOffset);
|
||||
(void)taosCloseFile(&pFile);
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -392,8 +392,8 @@ int32_t walCheckAndRepairMeta(SWal* pWal) {
|
|||
regex_t logRegPattern;
|
||||
regex_t idxRegPattern;
|
||||
|
||||
regcomp(&logRegPattern, logPattern, REG_EXTENDED);
|
||||
regcomp(&idxRegPattern, idxPattern, REG_EXTENDED);
|
||||
(void)regcomp(&logRegPattern, logPattern, REG_EXTENDED);
|
||||
(void)regcomp(&idxRegPattern, idxPattern, REG_EXTENDED);
|
||||
|
||||
TdDirPtr pDir = taosOpenDir(pWal->path);
|
||||
if (pDir == NULL) {
|
||||
|
@ -412,13 +412,13 @@ int32_t walCheckAndRepairMeta(SWal* pWal) {
|
|||
int code = regexec(&logRegPattern, name, 0, NULL, 0);
|
||||
if (code == 0) {
|
||||
SWalFileInfo fileInfo;
|
||||
memset(&fileInfo, -1, sizeof(SWalFileInfo));
|
||||
sscanf(name, "%" PRId64 ".log", &fileInfo.firstVer);
|
||||
taosArrayPush(actualLog, &fileInfo);
|
||||
(void)memset(&fileInfo, -1, sizeof(SWalFileInfo));
|
||||
(void)sscanf(name, "%" PRId64 ".log", &fileInfo.firstVer);
|
||||
(void)taosArrayPush(actualLog, &fileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
taosCloseDir(&pDir);
|
||||
(void)taosCloseDir(&pDir);
|
||||
regfree(&logRegPattern);
|
||||
regfree(&idxRegPattern);
|
||||
|
||||
|
@ -549,7 +549,7 @@ static int32_t walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
|
|||
TdFilePtr pIdxFile = NULL;
|
||||
SWalIdxEntry idxEntry = {.ver = pFileInfo->firstVer - 1, .offset = -sizeof(SWalCkHead)};
|
||||
SWalCkHead ckHead;
|
||||
memset(&ckHead, 0, sizeof(ckHead));
|
||||
(void)memset(&ckHead, 0, sizeof(ckHead));
|
||||
ckHead.head.version = idxEntry.ver;
|
||||
|
||||
pIdxFile = taosOpenFile(fnameStr, TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE);
|
||||
|
@ -675,7 +675,7 @@ _err:
|
|||
int64_t walGetVerRetention(SWal* pWal, int64_t bytes) {
|
||||
int64_t ver = -1;
|
||||
int64_t totSize = 0;
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
(void)taosThreadMutexLock(&pWal->mutex);
|
||||
int32_t fileIdx = taosArrayGetSize(pWal->fileInfoSet);
|
||||
while (--fileIdx) {
|
||||
SWalFileInfo* pInfo = taosArrayGet(pWal->fileInfoSet, fileIdx);
|
||||
|
@ -685,7 +685,7 @@ int64_t walGetVerRetention(SWal* pWal, int64_t bytes) {
|
|||
}
|
||||
totSize += pInfo->fileSize;
|
||||
}
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
(void)taosThreadMutexUnlock(&pWal->mutex);
|
||||
return ver + 1;
|
||||
}
|
||||
|
||||
|
@ -727,7 +727,7 @@ int32_t walRollFileInfo(SWal* pWal) {
|
|||
pNewInfo->closeTs = -1;
|
||||
pNewInfo->fileSize = 0;
|
||||
pNewInfo->syncedOffset = 0;
|
||||
taosArrayPush(pArray, pNewInfo);
|
||||
(void)taosArrayPush(pArray, pNewInfo);
|
||||
taosMemoryFree(pNewInfo);
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
|
@ -753,21 +753,21 @@ int32_t walMetaSerialize(SWal* pWal, char** serialized) {
|
|||
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
cJSON_AddItemToObject(pRoot, "meta", pMeta);
|
||||
sprintf(buf, "%" PRId64, pWal->vers.firstVer);
|
||||
cJSON_AddStringToObject(pMeta, "firstVer", buf);
|
||||
sprintf(buf, "%" PRId64, pWal->vers.snapshotVer);
|
||||
cJSON_AddStringToObject(pMeta, "snapshotVer", buf);
|
||||
sprintf(buf, "%" PRId64, pWal->vers.commitVer);
|
||||
cJSON_AddStringToObject(pMeta, "commitVer", buf);
|
||||
sprintf(buf, "%" PRId64, pWal->vers.lastVer);
|
||||
cJSON_AddStringToObject(pMeta, "lastVer", buf);
|
||||
(void)cJSON_AddItemToObject(pRoot, "meta", pMeta);
|
||||
(void)sprintf(buf, "%" PRId64, pWal->vers.firstVer);
|
||||
(void)cJSON_AddStringToObject(pMeta, "firstVer", buf);
|
||||
(void)sprintf(buf, "%" PRId64, pWal->vers.snapshotVer);
|
||||
(void)cJSON_AddStringToObject(pMeta, "snapshotVer", buf);
|
||||
(void)sprintf(buf, "%" PRId64, pWal->vers.commitVer);
|
||||
(void)cJSON_AddStringToObject(pMeta, "commitVer", buf);
|
||||
(void)sprintf(buf, "%" PRId64, pWal->vers.lastVer);
|
||||
(void)cJSON_AddStringToObject(pMeta, "lastVer", buf);
|
||||
|
||||
cJSON_AddItemToObject(pRoot, "files", pFiles);
|
||||
(void)cJSON_AddItemToObject(pRoot, "files", pFiles);
|
||||
SWalFileInfo* pData = pWal->fileInfoSet->pData;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
SWalFileInfo* pInfo = &pData[i];
|
||||
cJSON_AddItemToArray(pFiles, pField = cJSON_CreateObject());
|
||||
(void)cJSON_AddItemToArray(pFiles, pField = cJSON_CreateObject());
|
||||
if (pField == NULL) {
|
||||
cJSON_Delete(pRoot);
|
||||
|
||||
|
@ -775,16 +775,16 @@ int32_t walMetaSerialize(SWal* pWal, char** serialized) {
|
|||
}
|
||||
// cjson only support int32_t or double
|
||||
// string are used to prohibit the loss of precision
|
||||
sprintf(buf, "%" PRId64, pInfo->firstVer);
|
||||
cJSON_AddStringToObject(pField, "firstVer", buf);
|
||||
sprintf(buf, "%" PRId64, pInfo->lastVer);
|
||||
cJSON_AddStringToObject(pField, "lastVer", buf);
|
||||
sprintf(buf, "%" PRId64, pInfo->createTs);
|
||||
cJSON_AddStringToObject(pField, "createTs", buf);
|
||||
sprintf(buf, "%" PRId64, pInfo->closeTs);
|
||||
cJSON_AddStringToObject(pField, "closeTs", buf);
|
||||
sprintf(buf, "%" PRId64, pInfo->fileSize);
|
||||
cJSON_AddStringToObject(pField, "fileSize", buf);
|
||||
(void)sprintf(buf, "%" PRId64, pInfo->firstVer);
|
||||
(void)cJSON_AddStringToObject(pField, "firstVer", buf);
|
||||
(void)sprintf(buf, "%" PRId64, pInfo->lastVer);
|
||||
(void)cJSON_AddStringToObject(pField, "lastVer", buf);
|
||||
(void)sprintf(buf, "%" PRId64, pInfo->createTs);
|
||||
(void)cJSON_AddStringToObject(pField, "createTs", buf);
|
||||
(void)sprintf(buf, "%" PRId64, pInfo->closeTs);
|
||||
(void)cJSON_AddStringToObject(pField, "closeTs", buf);
|
||||
(void)sprintf(buf, "%" PRId64, pInfo->fileSize);
|
||||
(void)cJSON_AddStringToObject(pField, "fileSize", buf);
|
||||
}
|
||||
char* pSerialized = cJSON_Print(pRoot);
|
||||
cJSON_Delete(pRoot);
|
||||
|
@ -818,7 +818,7 @@ int32_t walMetaDeserialize(SWal* pWal, const char* bytes) {
|
|||
int sz = cJSON_GetArraySize(pFiles);
|
||||
// deserialize
|
||||
SArray* pArray = pWal->fileInfoSet;
|
||||
taosArrayEnsureCap(pArray, sz);
|
||||
(void)taosArrayEnsureCap(pArray, sz);
|
||||
|
||||
for (int i = 0; i < sz; i++) {
|
||||
pInfoJson = cJSON_GetArrayItem(pFiles, i);
|
||||
|
@ -841,7 +841,7 @@ int32_t walMetaDeserialize(SWal* pWal, const char* bytes) {
|
|||
pField = cJSON_GetObjectItem(pInfoJson, "fileSize");
|
||||
if (!pField) goto _err;
|
||||
info.fileSize = atoll(cJSON_GetStringValue(pField));
|
||||
taosArrayPush(pArray, &info);
|
||||
(void)taosArrayPush(pArray, &info);
|
||||
}
|
||||
pWal->fileInfoSet = pArray;
|
||||
pWal->writeCur = sz - 1;
|
||||
|
@ -856,7 +856,7 @@ _err:
|
|||
static int walFindCurMetaVer(SWal* pWal) {
|
||||
const char* pattern = "^meta-ver[0-9]+$";
|
||||
regex_t walMetaRegexPattern;
|
||||
regcomp(&walMetaRegexPattern, pattern, REG_EXTENDED);
|
||||
(void)regcomp(&walMetaRegexPattern, pattern, REG_EXTENDED);
|
||||
|
||||
TdDirPtr pDir = taosOpenDir(pWal->path);
|
||||
if (pDir == NULL) {
|
||||
|
@ -872,13 +872,13 @@ static int walFindCurMetaVer(SWal* pWal) {
|
|||
char* name = taosDirEntryBaseName(taosGetDirEntryName(pDirEntry));
|
||||
int code = regexec(&walMetaRegexPattern, name, 0, NULL, 0);
|
||||
if (code == 0) {
|
||||
sscanf(name, "meta-ver%d", &metaVer);
|
||||
(void)sscanf(name, "meta-ver%d", &metaVer);
|
||||
wDebug("vgId:%d, wal find current meta: %s is the meta file, ver %d", pWal->cfg.vgId, name, metaVer);
|
||||
break;
|
||||
}
|
||||
wDebug("vgId:%d, wal find current meta: %s is not meta file", pWal->cfg.vgId, name);
|
||||
}
|
||||
taosCloseDir(&pDir);
|
||||
(void)taosCloseDir(&pDir);
|
||||
regfree(&walMetaRegexPattern);
|
||||
return metaVer;
|
||||
}
|
||||
|
@ -961,8 +961,8 @@ int32_t walSaveMeta(SWal* pWal) {
|
|||
|
||||
// delete old file
|
||||
if (metaVer > -1) {
|
||||
walBuildMetaName(pWal, metaVer, fnameStr);
|
||||
taosRemoveFile(fnameStr);
|
||||
(void)walBuildMetaName(pWal, metaVer, fnameStr);
|
||||
(void)taosRemoveFile(fnameStr);
|
||||
}
|
||||
|
||||
taosMemoryFree(serialized);
|
||||
|
@ -984,10 +984,10 @@ int32_t walLoadMeta(SWal* pWal) {
|
|||
TAOS_RETURN(TSDB_CODE_FAILED);
|
||||
}
|
||||
char fnameStr[WAL_FILE_LEN];
|
||||
walBuildMetaName(pWal, metaVer, fnameStr);
|
||||
(void)walBuildMetaName(pWal, metaVer, fnameStr);
|
||||
// read metafile
|
||||
int64_t fileSize = 0;
|
||||
taosStatFile(fnameStr, &fileSize, NULL, NULL);
|
||||
(void)taosStatFile(fnameStr, &fileSize, NULL, NULL);
|
||||
if (fileSize == 0) {
|
||||
(void)taosRemoveFile(fnameStr);
|
||||
wDebug("vgId:%d, wal find empty meta ver %d", pWal->cfg.vgId, metaVer);
|
||||
|
@ -999,7 +999,7 @@ int32_t walLoadMeta(SWal* pWal) {
|
|||
if (buf == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
memset(buf, 0, size + 5);
|
||||
(void)memset(buf, 0, size + 5);
|
||||
TdFilePtr pFile = taosOpenFile(fnameStr, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
taosMemoryFree(buf);
|
||||
|
@ -1007,7 +1007,7 @@ int32_t walLoadMeta(SWal* pWal) {
|
|||
TAOS_RETURN(TSDB_CODE_WAL_FILE_CORRUPTED);
|
||||
}
|
||||
if (taosReadFile(pFile, buf, size) != size) {
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
taosMemoryFree(buf);
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
|
@ -1018,7 +1018,7 @@ int32_t walLoadMeta(SWal* pWal) {
|
|||
wError("failed to deserialize wal meta. file:%s", fnameStr);
|
||||
code = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||
}
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
taosMemoryFree(buf);
|
||||
|
||||
TAOS_RETURN(code);
|
||||
|
@ -1028,6 +1028,6 @@ int32_t walRemoveMeta(SWal* pWal) {
|
|||
int metaVer = walFindCurMetaVer(pWal);
|
||||
if (metaVer == -1) return 0;
|
||||
char fnameStr[WAL_FILE_LEN];
|
||||
walBuildMetaName(pWal, metaVer, fnameStr);
|
||||
(void)walBuildMetaName(pWal, metaVer, fnameStr);
|
||||
return taosRemoveFile(fnameStr);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ static int32_t walCreateThread();
|
|||
static void walStopThread();
|
||||
static void walFreeObj(void *pWal);
|
||||
|
||||
int64_t walGetSeq() { return (int64_t)atomic_load_32(&tsWal.seq); }
|
||||
int64_t walGetSeq() { return (int64_t)atomic_load_32((volatile int32_t *)&tsWal.seq); }
|
||||
|
||||
int32_t walInit() {
|
||||
int8_t old;
|
||||
|
@ -69,7 +69,7 @@ void walCleanUp() {
|
|||
|
||||
if (old == 1) {
|
||||
walStopThread();
|
||||
taosCloseRef(tsWal.refSetId);
|
||||
TAOS_UNUSED(taosCloseRef(tsWal.refSetId));
|
||||
wInfo("wal module is cleaned up");
|
||||
atomic_store_8(&tsWal.inited, 0);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) {
|
|||
}
|
||||
|
||||
// set config
|
||||
memcpy(&pWal->cfg, pCfg, sizeof(SWalCfg));
|
||||
TAOS_UNUSED(memcpy(&pWal->cfg, pCfg, sizeof(SWalCfg)));
|
||||
|
||||
pWal->fsyncSeq = pCfg->fsyncPeriod / 1000;
|
||||
if (pWal->cfg.retentionSize > 0) {
|
||||
|
@ -140,7 +140,7 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) {
|
|||
pWal->lastRollSeq = -1;
|
||||
|
||||
// init write buffer
|
||||
memset(&pWal->writeHead, 0, sizeof(SWalCkHead));
|
||||
TAOS_UNUSED(memset(&pWal->writeHead, 0, sizeof(SWalCkHead)));
|
||||
pWal->writeHead.head.protoVer = WAL_PROTO_VER;
|
||||
pWal->writeHead.magic = WAL_MAGIC;
|
||||
|
||||
|
@ -171,7 +171,7 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) {
|
|||
_err:
|
||||
taosArrayDestroy(pWal->fileInfoSet);
|
||||
taosHashCleanup(pWal->pRefHash);
|
||||
taosThreadMutexDestroy(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexDestroy(&pWal->mutex));
|
||||
taosMemoryFreeClear(pWal);
|
||||
|
||||
return NULL;
|
||||
|
@ -207,19 +207,19 @@ int32_t walAlter(SWal *pWal, SWalCfg *pCfg) {
|
|||
int32_t walPersist(SWal *pWal) {
|
||||
int32_t code = 0;
|
||||
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
code = walSaveMeta(pWal);
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
void walClose(SWal *pWal) {
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
(void)walSaveMeta(pWal);
|
||||
taosCloseFile(&pWal->pLogFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pWal->pLogFile));
|
||||
pWal->pLogFile = NULL;
|
||||
taosCloseFile(&pWal->pIdxFile);
|
||||
(void)taosCloseFile(&pWal->pIdxFile);
|
||||
pWal->pIdxFile = NULL;
|
||||
taosArrayDestroy(pWal->fileInfoSet);
|
||||
pWal->fileInfoSet = NULL;
|
||||
|
@ -235,22 +235,22 @@ void walClose(SWal *pWal) {
|
|||
}
|
||||
taosHashCleanup(pWal->pRefHash);
|
||||
pWal->pRefHash = NULL;
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
(void)taosThreadMutexUnlock(&pWal->mutex);
|
||||
|
||||
if (pWal->cfg.level == TAOS_WAL_SKIP) {
|
||||
wInfo("vgId:%d, remove all wals, path:%s", pWal->cfg.vgId, pWal->path);
|
||||
taosRemoveDir(pWal->path);
|
||||
taosMkDir(pWal->path);
|
||||
(void)taosMkDir(pWal->path);
|
||||
}
|
||||
|
||||
taosRemoveRef(tsWal.refSetId, pWal->refId);
|
||||
(void)taosRemoveRef(tsWal.refSetId, pWal->refId);
|
||||
}
|
||||
|
||||
static void walFreeObj(void *wal) {
|
||||
SWal *pWal = wal;
|
||||
wDebug("vgId:%d, wal:%p is freed", pWal->cfg.vgId, pWal);
|
||||
|
||||
taosThreadMutexDestroy(&pWal->mutex);
|
||||
(void)taosThreadMutexDestroy(&pWal->mutex);
|
||||
taosMemoryFreeClear(pWal);
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ static bool walNeedFsync(SWal *pWal) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (atomic_load_32(&tsWal.seq) % pWal->fsyncSeq == 0) {
|
||||
if (atomic_load_32((volatile int32_t *)&tsWal.seq) % pWal->fsyncSeq == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ static bool walNeedFsync(SWal *pWal) {
|
|||
|
||||
static void walUpdateSeq() {
|
||||
taosMsleep(WAL_REFRESH_MS);
|
||||
atomic_add_fetch_32(&tsWal.seq, 1);
|
||||
(void)atomic_add_fetch_32((volatile int32_t *)&tsWal.seq, 1);
|
||||
}
|
||||
|
||||
static void walFsyncAll() {
|
||||
|
@ -276,7 +276,7 @@ static void walFsyncAll() {
|
|||
while (pWal) {
|
||||
if (walNeedFsync(pWal)) {
|
||||
wTrace("vgId:%d, do fsync, level:%d seq:%d rseq:%d", pWal->cfg.vgId, pWal->cfg.level, pWal->fsyncSeq,
|
||||
atomic_load_32(&tsWal.seq));
|
||||
atomic_load_32((volatile int32_t *)&tsWal.seq));
|
||||
int32_t code = taosFsyncFile(pWal->pLogFile);
|
||||
if (code != 0) {
|
||||
wError("vgId:%d, file:%" PRId64 ".log, failed to fsync since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
|
||||
|
@ -301,8 +301,8 @@ static void *walThreadFunc(void *param) {
|
|||
|
||||
static int32_t walCreateThread() {
|
||||
TdThreadAttr thAttr;
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
if (taosThreadCreate(&tsWal.thread, &thAttr, walThreadFunc, NULL) != 0) {
|
||||
wError("failed to create wal thread since %s", strerror(errno));
|
||||
|
@ -310,7 +310,7 @@ static int32_t walCreateThread() {
|
|||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
wDebug("wal thread is launched, thread:0x%08" PRIx64, taosGetPthreadId(tsWal.thread));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
|
@ -320,7 +320,7 @@ static void walStopThread() {
|
|||
atomic_store_8(&tsWal.stop, 1);
|
||||
|
||||
if (taosCheckPthreadValid(tsWal.thread)) {
|
||||
taosThreadJoin(tsWal.thread, NULL);
|
||||
(void)taosThreadJoin(tsWal.thread, NULL);
|
||||
taosThreadClear(&tsWal.thread);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ SWalReader *walOpenReader(SWal *pWal, SWalFilterCond *cond, int64_t id) {
|
|||
pReader->cond.enableRef = 0;
|
||||
}
|
||||
|
||||
taosThreadMutexInit(&pReader->mutex, NULL);
|
||||
TAOS_UNUSED(taosThreadMutexInit(&pReader->mutex, NULL));
|
||||
|
||||
pReader->pHead = taosMemoryMalloc(sizeof(SWalCkHead));
|
||||
if (pReader->pHead == NULL) {
|
||||
|
@ -60,8 +60,8 @@ SWalReader *walOpenReader(SWal *pWal, SWalFilterCond *cond, int64_t id) {
|
|||
void walCloseReader(SWalReader *pReader) {
|
||||
if (pReader == NULL) return;
|
||||
|
||||
taosCloseFile(&pReader->pIdxFile);
|
||||
taosCloseFile(&pReader->pLogFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pReader->pIdxFile));
|
||||
TAOS_UNUSED(taosCloseFile(&pReader->pLogFile));
|
||||
taosMemoryFreeClear(pReader->pHead);
|
||||
taosMemoryFree(pReader);
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ void walReaderValidVersionRange(SWalReader *pReader, int64_t *sver, int64_t *eve
|
|||
|
||||
void walReaderVerifyOffset(SWalReader *pWalReader, STqOffsetVal *pOffset) {
|
||||
// if offset version is small than first version , let's seek to first version
|
||||
taosThreadMutexLock(&pWalReader->pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWalReader->pWal->mutex));
|
||||
int64_t firstVer = walGetFirstVer((pWalReader)->pWal);
|
||||
taosThreadMutexUnlock(&pWalReader->pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWalReader->pWal->mutex));
|
||||
|
||||
if (pOffset->version < firstVer) {
|
||||
pOffset->version = firstVer;
|
||||
|
@ -167,8 +167,8 @@ static int32_t walReadSeekFilePos(SWalReader *pReader, int64_t fileFirstVer, int
|
|||
static int32_t walReadChangeFile(SWalReader *pReader, int64_t fileFirstVer) {
|
||||
char fnameStr[WAL_FILE_LEN] = {0};
|
||||
|
||||
taosCloseFile(&pReader->pIdxFile);
|
||||
taosCloseFile(&pReader->pLogFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pReader->pIdxFile));
|
||||
TAOS_UNUSED(taosCloseFile(&pReader->pLogFile));
|
||||
|
||||
walBuildLogName(pReader->pWal, fileFirstVer, fnameStr);
|
||||
TdFilePtr pLogFile = taosOpenFile(fnameStr, TD_FILE_READ);
|
||||
|
@ -393,13 +393,13 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
|||
TAOS_RETURN(TSDB_CODE_WAL_LOG_NOT_EXIST);
|
||||
}
|
||||
|
||||
taosThreadMutexLock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pReader->mutex));
|
||||
|
||||
if (pReader->curVersion != ver) {
|
||||
code = walReaderSeekVer(pReader, ver);
|
||||
if (code) {
|
||||
wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since %s", pReader->pWal->cfg.vgId, ver, terrstr());
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
|||
} else if (contLen == 0 && !seeked) {
|
||||
code = walReadSeekVerImpl(pReader, ver);
|
||||
if (code) {
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
|||
} else {
|
||||
wError("vgId:%d, failed to read WAL record head, index:%" PRId64 ", from log file since %s",
|
||||
pReader->pWal->cfg.vgId, ver, terrstr());
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
|
||||
if (contLen < 0) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
|
@ -437,7 +437,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
|||
if (code != 0) {
|
||||
wError("vgId:%d, unexpected wal log, index:%" PRId64 ", since head checksum not passed", pReader->pWal->cfg.vgId,
|
||||
ver);
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_WAL_FILE_CORRUPTED);
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
|||
if (pReader->capacity < cryptedBodyLen) {
|
||||
SWalCkHead *ptr = (SWalCkHead *)taosMemoryRealloc(pReader->pHead, sizeof(SWalCkHead) + cryptedBodyLen);
|
||||
if (ptr == NULL) {
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
|||
if ((contLen = taosReadFile(pReader->pLogFile, pReader->pHead->head.body, cryptedBodyLen)) != cryptedBodyLen) {
|
||||
wError("vgId:%d, failed to read WAL record body, index:%" PRId64 ", from log file since %s",
|
||||
pReader->pWal->cfg.vgId, ver, terrstr());
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
|
||||
if (contLen < 0) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
|
@ -477,14 +477,14 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
|||
wError("vgId:%d, unexpected wal log, index:%" PRId64 ", read request index:%" PRId64, pReader->pWal->cfg.vgId,
|
||||
pReader->pHead->head.version, ver);
|
||||
// pReader->curInvalid = 1;
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_WAL_FILE_CORRUPTED);
|
||||
}
|
||||
|
||||
code = decryptBody(&pReader->pWal->cfg, pReader->pHead, plainBodyLen, __FUNCTION__);
|
||||
if (code) {
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -498,13 +498,13 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
|||
wError("checksum written into log:%u, checksum calculated:%u", logCkSum, readCkSum);
|
||||
// pReader->curInvalid = 1;
|
||||
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_WAL_FILE_CORRUPTED);
|
||||
}
|
||||
pReader->curVersion++;
|
||||
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -523,13 +523,13 @@ int32_t decryptBody(SWalCfg *cfg, SWalCkHead *pHead, int32_t plainBodyLen, const
|
|||
opts.source = pHead->head.body;
|
||||
opts.result = newBody;
|
||||
opts.unitLen = 16;
|
||||
strncpy(opts.key, cfg->encryptKey, 16);
|
||||
TAOS_UNUSED(strncpy((char *)opts.key, cfg->encryptKey, 16));
|
||||
|
||||
int32_t count = CBC_Decrypt(&opts);
|
||||
|
||||
// wDebug("CBC_Decrypt cryptedBodyLen:%d, plainBodyLen:%d, %s", count, plainBodyLen, func);
|
||||
|
||||
memcpy(pHead->head.body, newBody, plainBodyLen);
|
||||
TAOS_UNUSED(memcpy(pHead->head.body, newBody, plainBodyLen));
|
||||
|
||||
taosMemoryFree(newBody);
|
||||
}
|
||||
|
@ -538,10 +538,10 @@ int32_t decryptBody(SWalCfg *cfg, SWalCkHead *pHead, int32_t plainBodyLen, const
|
|||
}
|
||||
|
||||
void walReadReset(SWalReader *pReader) {
|
||||
taosThreadMutexLock(&pReader->mutex);
|
||||
taosCloseFile(&pReader->pIdxFile);
|
||||
taosCloseFile(&pReader->pLogFile);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pReader->mutex));
|
||||
TAOS_UNUSED(taosCloseFile(&pReader->pIdxFile));
|
||||
TAOS_UNUSED(taosCloseFile(&pReader->pLogFile));
|
||||
pReader->curFileFirstVer = -1;
|
||||
pReader->curVersion = -1;
|
||||
taosThreadMutexUnlock(&pReader->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pReader->mutex));
|
||||
}
|
||||
|
|
|
@ -61,34 +61,34 @@ int32_t walSetRefVer(SWalRef *pRef, int64_t ver) {
|
|||
SWal *pWal = pRef->pWal;
|
||||
wDebug("vgId:%d, wal ref version %" PRId64 ", refId %" PRId64, pWal->cfg.vgId, ver, pRef->refId);
|
||||
if (pRef->refVer != ver) {
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
if (ver < pWal->vers.firstVer || ver > pWal->vers.lastVer) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_WAL_INVALID_VER);
|
||||
}
|
||||
|
||||
pRef->refVer = ver;
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
}
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
void walRefFirstVer(SWal *pWal, SWalRef *pRef) {
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
|
||||
pRef->refVer = pWal->vers.firstVer;
|
||||
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
wDebug("vgId:%d, wal ref version %" PRId64 " for first", pWal->cfg.vgId, pRef->refVer);
|
||||
}
|
||||
|
||||
void walRefLastVer(SWal *pWal, SWalRef *pRef) {
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
|
||||
pRef->refVer = pWal->vers.lastVer;
|
||||
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
wDebug("vgId:%d, wal ref version %" PRId64 " for last", pWal->cfg.vgId, pRef->refVer);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
|
||||
int32_t code = 0;
|
||||
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
|
||||
wInfo("vgId:%d, restore from snapshot, version %" PRId64, pWal->cfg.vgId, ver);
|
||||
|
||||
|
@ -34,14 +34,14 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
|
|||
SWalRef *pRef = *(SWalRef **)pIter;
|
||||
if (pRef->refVer != -1 && pRef->refVer <= ver) {
|
||||
taosHashCancelIterate(pWal->pRefHash, pIter);
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
taosCloseFile(&pWal->pLogFile);
|
||||
taosCloseFile(&pWal->pIdxFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pWal->pLogFile));
|
||||
TAOS_UNUSED(taosCloseFile(&pWal->pIdxFile));
|
||||
|
||||
if (pWal->vers.firstVer != -1) {
|
||||
int32_t fileSetSize = taosArrayGetSize(pWal->fileInfoSet);
|
||||
|
@ -51,7 +51,7 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
|
|||
walBuildLogName(pWal, pFileInfo->firstVer, fnameStr);
|
||||
if (taosRemoveFile(fnameStr) < 0) {
|
||||
wError("vgId:%d, restore from snapshot, cannot remove file %s since %s", pWal->cfg.vgId, fnameStr, terrstr());
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
|
|||
walBuildIdxName(pWal, pFileInfo->firstVer, fnameStr);
|
||||
if (taosRemoveFile(fnameStr) < 0) {
|
||||
wError("vgId:%d, cannot remove file %s since %s", pWal->cfg.vgId, fnameStr, terrstr());
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
|
|||
pWal->vers.snapshotVer = ver;
|
||||
pWal->vers.verInSnapshotting = -1;
|
||||
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ static int64_t walChangeWrite(SWal *pWal, int64_t ver) {
|
|||
walBuildLogName(pWal, fileFirstVer, fnameStr);
|
||||
pLogTFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||
if (pLogTFile == NULL) {
|
||||
taosCloseFile(&pIdxTFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pIdxTFile));
|
||||
pWal->pLogFile = NULL;
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
|
@ -160,12 +160,12 @@ static int64_t walChangeWrite(SWal *pWal, int64_t ver) {
|
|||
}
|
||||
|
||||
int32_t walRollback(SWal *pWal, int64_t ver) {
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
wInfo("vgId:%d, wal rollback for version %" PRId64, pWal->cfg.vgId, ver);
|
||||
int64_t code;
|
||||
char fnameStr[WAL_FILE_LEN];
|
||||
if (ver > pWal->vers.lastVer || ver <= pWal->vers.commitVer || ver <= pWal->vers.snapshotVer) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_WAL_INVALID_VER);
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
|
|||
// change current files
|
||||
code = walChangeWrite(pWal, ver);
|
||||
if (code < 0) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -187,50 +187,50 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
|
|||
|
||||
walBuildLogName(pWal, pInfo->firstVer, fnameStr);
|
||||
wDebug("vgId:%d, wal remove file %s for rollback", pWal->cfg.vgId, fnameStr);
|
||||
taosRemoveFile(fnameStr);
|
||||
TAOS_UNUSED(taosRemoveFile(fnameStr));
|
||||
walBuildIdxName(pWal, pInfo->firstVer, fnameStr);
|
||||
wDebug("vgId:%d, wal remove file %s for rollback", pWal->cfg.vgId, fnameStr);
|
||||
taosRemoveFile(fnameStr);
|
||||
TAOS_UNUSED(taosRemoveFile(fnameStr));
|
||||
}
|
||||
}
|
||||
|
||||
walBuildIdxName(pWal, walGetCurFileFirstVer(pWal), fnameStr);
|
||||
taosCloseFile(&pWal->pIdxFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pWal->pIdxFile));
|
||||
TdFilePtr pIdxFile = taosOpenFile(fnameStr, TD_FILE_WRITE | TD_FILE_READ | TD_FILE_APPEND);
|
||||
if (pIdxFile == NULL) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
int64_t idxOff = walGetVerIdxOffset(pWal, ver);
|
||||
code = taosLSeekFile(pIdxFile, idxOff, SEEK_SET);
|
||||
if (code < 0) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
// read idx file and get log file pos
|
||||
SWalIdxEntry entry;
|
||||
if (taosReadFile(pIdxFile, &entry, sizeof(SWalIdxEntry)) != sizeof(SWalIdxEntry)) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
||||
walBuildLogName(pWal, walGetCurFileFirstVer(pWal), fnameStr);
|
||||
taosCloseFile(&pWal->pLogFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pWal->pLogFile));
|
||||
TdFilePtr pLogFile = taosOpenFile(fnameStr, TD_FILE_WRITE | TD_FILE_READ | TD_FILE_APPEND);
|
||||
wDebug("vgId:%d, wal truncate file %s", pWal->cfg.vgId, fnameStr);
|
||||
if (pLogFile == NULL) {
|
||||
// TODO
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
code = taosLSeekFile(pLogFile, entry.offset, SEEK_SET);
|
||||
if (code < 0) {
|
||||
// TODO
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
@ -238,19 +238,19 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
|
|||
SWalCkHead head;
|
||||
int64_t size = taosReadFile(pLogFile, &head, sizeof(SWalCkHead));
|
||||
if (size != sizeof(SWalCkHead)) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
code = walValidHeadCksum(&head);
|
||||
|
||||
if (code != 0) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_WAL_FILE_CORRUPTED);
|
||||
}
|
||||
if (head.head.version != ver) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_WAL_FILE_CORRUPTED);
|
||||
}
|
||||
|
@ -258,13 +258,13 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
|
|||
// truncate old files
|
||||
code = taosFtruncateFile(pLogFile, entry.offset);
|
||||
if (code < 0) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
code = taosFtruncateFile(pIdxFile, idxOff);
|
||||
if (code < 0) {
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
|
@ -272,19 +272,19 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
|
|||
((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->lastVer = ver - 1;
|
||||
((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->fileSize = entry.offset;
|
||||
|
||||
taosCloseFile(&pIdxFile);
|
||||
taosCloseFile(&pLogFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pIdxFile));
|
||||
TAOS_UNUSED(taosCloseFile(&pLogFile));
|
||||
|
||||
code = walSaveMeta(pWal);
|
||||
if (code < 0) {
|
||||
wError("vgId:%d, failed to save meta since %s", pWal->cfg.vgId, terrstr());
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
// unlock
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ static FORCE_INLINE int32_t walCheckAndRoll(SWal *pWal) {
|
|||
int32_t walBeginSnapshot(SWal *pWal, int64_t ver, int64_t logRetention) {
|
||||
int32_t code = 0;
|
||||
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
ASSERT(logRetention >= 0);
|
||||
pWal->vers.verInSnapshotting = ver;
|
||||
pWal->vers.logRetention = logRetention;
|
||||
|
@ -388,7 +388,7 @@ int32_t walBeginSnapshot(SWal *pWal, int64_t ver, int64_t logRetention) {
|
|||
}
|
||||
|
||||
_exit:
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ _exit:
|
|||
int32_t walEndSnapshot(SWal *pWal) {
|
||||
int32_t code = 0, lino = 0;
|
||||
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
int64_t ver = pWal->vers.verInSnapshotting;
|
||||
|
||||
wDebug("vgId:%d, wal end snapshot for version %" PRId64 ", log retention %" PRId64 " first ver %" PRId64
|
||||
|
@ -456,7 +456,7 @@ int32_t walEndSnapshot(SWal *pWal) {
|
|||
}
|
||||
for (SWalFileInfo *iter = pWal->fileInfoSet->pData; iter <= pUntil; iter++) {
|
||||
deleteCnt++;
|
||||
taosArrayPush(pWal->toDeleteFiles, iter);
|
||||
TAOS_UNUSED(taosArrayPush(pWal->toDeleteFiles, iter));
|
||||
}
|
||||
|
||||
// make new array, remove files
|
||||
|
@ -589,8 +589,8 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
|||
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit);
|
||||
}
|
||||
memset(newBody, 0, cyptedBodyLen);
|
||||
memcpy(newBody, body, plainBodyLen);
|
||||
TAOS_UNUSED(memset(newBody, 0, cyptedBodyLen));
|
||||
TAOS_UNUSED(memcpy(newBody, body, plainBodyLen));
|
||||
|
||||
newBodyEncrypted = taosMemoryMalloc(cyptedBodyLen);
|
||||
if (newBodyEncrypted == NULL) {
|
||||
|
@ -607,7 +607,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
|||
opts.source = newBody;
|
||||
opts.result = newBodyEncrypted;
|
||||
opts.unitLen = 16;
|
||||
strncpy(opts.key, pWal->cfg.encryptKey, ENCRYPT_KEY_LEN);
|
||||
TAOS_UNUSED(strncpy((char *)opts.key, pWal->cfg.encryptKey, ENCRYPT_KEY_LEN));
|
||||
|
||||
int32_t count = CBC_Encrypt(&opts);
|
||||
|
||||
|
@ -698,7 +698,7 @@ int32_t walAppendLog(SWal *pWal, int64_t index, tmsg_t msgType, SWalSyncInfo syn
|
|||
int32_t bodyLen) {
|
||||
int32_t code = 0, lino = 0;
|
||||
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
|
||||
if (index != pWal->vers.lastVer + 1) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_WAL_INVALID_VER, &lino, _exit);
|
||||
|
@ -717,7 +717,7 @@ _exit:
|
|||
wError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -728,7 +728,7 @@ int32_t walFsync(SWal *pWal, bool forceFsync) {
|
|||
return code;
|
||||
}
|
||||
|
||||
taosThreadMutexLock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&pWal->mutex));
|
||||
if (forceFsync || (pWal->cfg.level == TAOS_WAL_FSYNC && pWal->cfg.fsyncPeriod == 0)) {
|
||||
wTrace("vgId:%d, fileId:%" PRId64 ".log, do fsync", pWal->cfg.vgId, walGetCurFileFirstVer(pWal));
|
||||
if (taosFsyncFile(pWal->pLogFile) < 0) {
|
||||
|
@ -737,7 +737,7 @@ int32_t walFsync(SWal *pWal, bool forceFsync) {
|
|||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
}
|
||||
}
|
||||
taosThreadMutexUnlock(&pWal->mutex);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -333,13 +333,13 @@ static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArr
|
|||
static void taosLRUCacheShardSetCapacity(SLRUCacheShard *shard, size_t capacity) {
|
||||
SArray *lastReferenceList = taosArrayInit(16, POINTER_BYTES);
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
shard->capacity = capacity;
|
||||
shard->highPriPoolCapacity = capacity * shard->highPriPoolRatio;
|
||||
taosLRUCacheShardEvictLRU(shard, 0, lastReferenceList);
|
||||
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(lastReferenceList); ++i) {
|
||||
SLRUEntry *entry = taosArrayGetP(lastReferenceList, i);
|
||||
|
@ -352,9 +352,9 @@ static int taosLRUCacheShardInit(SLRUCacheShard *shard, size_t capacity, bool st
|
|||
int maxUpperHashBits) {
|
||||
TAOS_CHECK_RETURN(taosLRUEntryTableInit(&shard->table, maxUpperHashBits));
|
||||
|
||||
taosThreadMutexInit(&shard->mutex, NULL);
|
||||
(void)taosThreadMutexInit(&shard->mutex, NULL);
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
shard->capacity = 0;
|
||||
shard->highPriPoolUsage = 0;
|
||||
shard->strictCapacity = strict;
|
||||
|
@ -367,7 +367,7 @@ static int taosLRUCacheShardInit(SLRUCacheShard *shard, size_t capacity, bool st
|
|||
shard->lru.next = &shard->lru;
|
||||
shard->lru.prev = &shard->lru;
|
||||
shard->lruLowPri = &shard->lru;
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
taosLRUCacheShardSetCapacity(shard, capacity);
|
||||
|
||||
|
@ -375,7 +375,7 @@ static int taosLRUCacheShardInit(SLRUCacheShard *shard, size_t capacity, bool st
|
|||
}
|
||||
|
||||
static void taosLRUCacheShardCleanup(SLRUCacheShard *shard) {
|
||||
taosThreadMutexDestroy(&shard->mutex);
|
||||
(void)taosThreadMutexDestroy(&shard->mutex);
|
||||
|
||||
taosLRUEntryTableCleanup(&shard->table);
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry *
|
|||
LRUStatus status = TAOS_LRU_STATUS_OK;
|
||||
SArray *lastReferenceList = taosArrayInit(16, POINTER_BYTES);
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
taosLRUCacheShardEvictLRU(shard, e->totalCharge, lastReferenceList);
|
||||
|
||||
|
@ -429,7 +429,7 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry *
|
|||
}
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(lastReferenceList); ++i) {
|
||||
SLRUEntry *entry = taosArrayGetP(lastReferenceList, i);
|
||||
|
@ -470,7 +470,7 @@ static LRUStatus taosLRUCacheShardInsert(SLRUCacheShard *shard, const void *key,
|
|||
static LRUHandle *taosLRUCacheShardLookup(SLRUCacheShard *shard, const void *key, size_t keyLen, uint32_t hash) {
|
||||
SLRUEntry *e = NULL;
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
e = taosLRUEntryTableLookup(&shard->table, key, keyLen, hash);
|
||||
if (e != NULL) {
|
||||
ASSERT(TAOS_LRU_ENTRY_IN_CACHE(e));
|
||||
|
@ -481,14 +481,14 @@ static LRUHandle *taosLRUCacheShardLookup(SLRUCacheShard *shard, const void *key
|
|||
TAOS_LRU_ENTRY_SET_HIT(e);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
return (LRUHandle *)e;
|
||||
}
|
||||
|
||||
static void taosLRUCacheShardErase(SLRUCacheShard *shard, const void *key, size_t keyLen, uint32_t hash) {
|
||||
bool lastReference = false;
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, key, keyLen, hash);
|
||||
if (e != NULL) {
|
||||
|
@ -503,7 +503,7 @@ static void taosLRUCacheShardErase(SLRUCacheShard *shard, const void *key, size_
|
|||
}
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
if (lastReference) {
|
||||
taosLRUEntryFree(e);
|
||||
|
@ -513,11 +513,11 @@ static void taosLRUCacheShardErase(SLRUCacheShard *shard, const void *key, size_
|
|||
static int taosLRUCacheShardApply(SLRUCacheShard *shard, _taos_lru_functor_t functor, void *ud) {
|
||||
int ret;
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
ret = taosLRUEntryTableApplyF(&shard->table, functor, ud);
|
||||
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ static int taosLRUCacheShardApply(SLRUCacheShard *shard, _taos_lru_functor_t fun
|
|||
static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) {
|
||||
SArray *lastReferenceList = taosArrayInit(16, POINTER_BYTES);
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
while (shard->lru.next != &shard->lru) {
|
||||
SLRUEntry *old = shard->lru.next;
|
||||
|
@ -539,7 +539,7 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) {
|
|||
taosArrayPush(lastReferenceList, &old);
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(lastReferenceList); ++i) {
|
||||
SLRUEntry *entry = taosArrayGetP(lastReferenceList, i);
|
||||
|
@ -552,12 +552,12 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) {
|
|||
|
||||
static bool taosLRUCacheShardRef(SLRUCacheShard *shard, LRUHandle *handle) {
|
||||
SLRUEntry *e = (SLRUEntry *)handle;
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
ASSERT(TAOS_LRU_ENTRY_HAS_REFS(e));
|
||||
TAOS_LRU_ENTRY_REF(e);
|
||||
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b
|
|||
SLRUEntry *e = (SLRUEntry *)handle;
|
||||
bool lastReference = false;
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
lastReference = taosLRUEntryUnref(e);
|
||||
if (lastReference && TAOS_LRU_ENTRY_IN_CACHE(e)) {
|
||||
|
@ -591,7 +591,7 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b
|
|||
shard->usage -= e->totalCharge;
|
||||
}
|
||||
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
if (lastReference) {
|
||||
taosLRUEntryFree(e);
|
||||
|
@ -603,9 +603,9 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b
|
|||
static size_t taosLRUCacheShardGetUsage(SLRUCacheShard *shard) {
|
||||
size_t usage = 0;
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
usage = shard->usage;
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
return usage;
|
||||
}
|
||||
|
@ -613,9 +613,9 @@ static size_t taosLRUCacheShardGetUsage(SLRUCacheShard *shard) {
|
|||
static int32_t taosLRUCacheShardGetElems(SLRUCacheShard *shard) {
|
||||
int32_t elems = 0;
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
elems = shard->table.elems;
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
return elems;
|
||||
}
|
||||
|
@ -623,22 +623,22 @@ static int32_t taosLRUCacheShardGetElems(SLRUCacheShard *shard) {
|
|||
static size_t taosLRUCacheShardGetPinnedUsage(SLRUCacheShard *shard) {
|
||||
size_t usage = 0;
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
ASSERT(shard->usage >= shard->lruUsage);
|
||||
usage = shard->usage - shard->lruUsage;
|
||||
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
return usage;
|
||||
}
|
||||
|
||||
static void taosLRUCacheShardSetStrictCapacity(SLRUCacheShard *shard, bool strict) {
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
(void)taosThreadMutexLock(&shard->mutex);
|
||||
|
||||
shard->strictCapacity = strict;
|
||||
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||
}
|
||||
|
||||
struct SShardedCache {
|
||||
|
@ -706,7 +706,7 @@ SLRUCache *taosLRUCacheInit(size_t capacity, int numShardBits, double highPriPoo
|
|||
cache->shardedCache.capacity = capacity;
|
||||
cache->shardedCache.lastId = 1;
|
||||
|
||||
taosThreadMutexInit(&cache->shardedCache.capacityMutex, NULL);
|
||||
(void)taosThreadMutexInit(&cache->shardedCache.capacityMutex, NULL);
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
@ -723,7 +723,7 @@ void taosLRUCacheCleanup(SLRUCache *cache) {
|
|||
cache->shards = 0;
|
||||
}
|
||||
|
||||
taosThreadMutexDestroy(&cache->shardedCache.capacityMutex);
|
||||
(void)taosThreadMutexDestroy(&cache->shardedCache.capacityMutex);
|
||||
|
||||
taosMemoryFree(cache);
|
||||
}
|
||||
|
@ -826,7 +826,7 @@ void taosLRUCacheSetCapacity(SLRUCache *cache, size_t capacity) {
|
|||
uint32_t numShards = cache->numShards;
|
||||
size_t perShard = (capacity + (numShards - 1)) / numShards;
|
||||
|
||||
taosThreadMutexLock(&cache->shardedCache.capacityMutex);
|
||||
(void)taosThreadMutexLock(&cache->shardedCache.capacityMutex);
|
||||
|
||||
for (int i = 0; i < numShards; ++i) {
|
||||
taosLRUCacheShardSetCapacity(&cache->shards[i], perShard);
|
||||
|
@ -834,17 +834,17 @@ void taosLRUCacheSetCapacity(SLRUCache *cache, size_t capacity) {
|
|||
|
||||
cache->shardedCache.capacity = capacity;
|
||||
|
||||
taosThreadMutexUnlock(&cache->shardedCache.capacityMutex);
|
||||
(void)taosThreadMutexUnlock(&cache->shardedCache.capacityMutex);
|
||||
}
|
||||
|
||||
size_t taosLRUCacheGetCapacity(SLRUCache *cache) {
|
||||
size_t capacity = 0;
|
||||
|
||||
taosThreadMutexLock(&cache->shardedCache.capacityMutex);
|
||||
(void)taosThreadMutexLock(&cache->shardedCache.capacityMutex);
|
||||
|
||||
capacity = cache->shardedCache.capacity;
|
||||
|
||||
taosThreadMutexUnlock(&cache->shardedCache.capacityMutex);
|
||||
(void)taosThreadMutexUnlock(&cache->shardedCache.capacityMutex);
|
||||
|
||||
return capacity;
|
||||
}
|
||||
|
@ -852,7 +852,7 @@ size_t taosLRUCacheGetCapacity(SLRUCache *cache) {
|
|||
void taosLRUCacheSetStrictCapacity(SLRUCache *cache, bool strict) {
|
||||
uint32_t numShards = cache->numShards;
|
||||
|
||||
taosThreadMutexLock(&cache->shardedCache.capacityMutex);
|
||||
(void)taosThreadMutexLock(&cache->shardedCache.capacityMutex);
|
||||
|
||||
for (int i = 0; i < numShards; ++i) {
|
||||
taosLRUCacheShardSetStrictCapacity(&cache->shards[i], strict);
|
||||
|
@ -860,17 +860,17 @@ void taosLRUCacheSetStrictCapacity(SLRUCache *cache, bool strict) {
|
|||
|
||||
cache->shardedCache.strictCapacity = strict;
|
||||
|
||||
taosThreadMutexUnlock(&cache->shardedCache.capacityMutex);
|
||||
(void)taosThreadMutexUnlock(&cache->shardedCache.capacityMutex);
|
||||
}
|
||||
|
||||
bool taosLRUCacheIsStrictCapacity(SLRUCache *cache) {
|
||||
bool strict = false;
|
||||
|
||||
taosThreadMutexLock(&cache->shardedCache.capacityMutex);
|
||||
(void)taosThreadMutexLock(&cache->shardedCache.capacityMutex);
|
||||
|
||||
strict = cache->shardedCache.strictCapacity;
|
||||
|
||||
taosThreadMutexUnlock(&cache->shardedCache.capacityMutex);
|
||||
(void)taosThreadMutexUnlock(&cache->shardedCache.capacityMutex);
|
||||
|
||||
return strict;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue