update return values

This commit is contained in:
Minglei Jin 2024-07-25 16:11:22 +08:00
parent 19819c4055
commit 5c8fef250c
2 changed files with 24 additions and 24 deletions

View File

@ -63,12 +63,12 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
pData->pWal = pSyncNode->pWal;
ASSERT(pData->pWal != NULL);
taosThreadMutexInit(&(pData->mutex), NULL);
(void)taosThreadMutexInit(&(pData->mutex), NULL);
pData->pWalHandle = walOpenReader(pData->pWal, NULL, 0);
if (!pData->pWalHandle) {
taosMemoryFree(pLogStore);
taosLRUCacheCleanup(pLogStore->pCache);
taosThreadMutexDestroy(&(pData->mutex));
(void)taosThreadMutexDestroy(&(pData->mutex));
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
@ -96,13 +96,13 @@ void logStoreDestory(SSyncLogStore* pLogStore) {
if (pLogStore != NULL) {
SSyncLogStoreData* pData = pLogStore->data;
taosThreadMutexLock(&(pData->mutex));
(void)taosThreadMutexLock(&(pData->mutex));
if (pData->pWalHandle != NULL) {
walCloseReader(pData->pWalHandle);
pData->pWalHandle = NULL;
}
taosThreadMutexUnlock(&(pData->mutex));
taosThreadMutexDestroy(&(pData->mutex));
(void)taosThreadMutexUnlock(&(pData->mutex));
(void)taosThreadMutexDestroy(&(pData->mutex));
taosMemoryFree(pLogStore->data);
@ -261,12 +261,12 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
*ppEntry = NULL;
int64_t ts1 = taosGetTimestampNs();
taosThreadMutexLock(&(pData->mutex));
(void)taosThreadMutexLock(&(pData->mutex));
SWalReader* pWalHandle = pData->pWalHandle;
if (pWalHandle == NULL) {
sError("vgId:%d, wal handle is NULL", pData->pSyncNode->vgId);
taosThreadMutexUnlock(&(pData->mutex));
(void)taosThreadMutexUnlock(&(pData->mutex));
TAOS_RETURN(TSDB_CODE_SYN_INTERNAL_ERROR);
}
@ -297,7 +297,7 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
terrno = saveErr;
*/
taosThreadMutexUnlock(&(pData->mutex));
(void)taosThreadMutexUnlock(&(pData->mutex));
TAOS_RETURN(code);
}
@ -311,7 +311,7 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
(*ppEntry)->term = pWalHandle->pHead->head.syncMeta.term;
(*ppEntry)->index = index;
ASSERT((*ppEntry)->dataLen == pWalHandle->pHead->head.bodyLen);
memcpy((*ppEntry)->data, pWalHandle->pHead->head.body, pWalHandle->pHead->head.bodyLen);
(void)memcpy((*ppEntry)->data, pWalHandle->pHead->head.body, pWalHandle->pHead->head.bodyLen);
/*
int32_t saveErr = terrno;
@ -319,7 +319,7 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
terrno = saveErr;
*/
taosThreadMutexUnlock(&(pData->mutex));
(void)taosThreadMutexUnlock(&(pData->mutex));
int64_t ts4 = taosGetTimestampNs();
int64_t tsElapsed = ts4 - ts1;

View File

@ -152,52 +152,52 @@ _OVER:
}
int32_t raftStoreOpen(SSyncNode *pNode) {
taosThreadMutexInit(&pNode->raftStore.mutex, NULL);
(void)taosThreadMutexInit(&pNode->raftStore.mutex, NULL);
return raftStoreReadFile(pNode);
}
void raftStoreClose(SSyncNode *pNode) { taosThreadMutexDestroy(&pNode->raftStore.mutex); }
void raftStoreClose(SSyncNode *pNode) { (void)taosThreadMutexDestroy(&pNode->raftStore.mutex); }
bool raftStoreHasVoted(SSyncNode *pNode) {
taosThreadMutexLock(&pNode->raftStore.mutex);
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
bool b = syncUtilEmptyId(&pNode->raftStore.voteFor);
taosThreadMutexUnlock(&pNode->raftStore.mutex);
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
return (!b);
}
void raftStoreVote(SSyncNode *pNode, SRaftId *pRaftId) {
taosThreadMutexLock(&pNode->raftStore.mutex);
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
pNode->raftStore.voteFor = *pRaftId;
(void)raftStoreWriteFile(pNode);
taosThreadMutexUnlock(&pNode->raftStore.mutex);
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
}
void raftStoreClearVote(SSyncNode *pNode) {
taosThreadMutexLock(&pNode->raftStore.mutex);
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
pNode->raftStore.voteFor = EMPTY_RAFT_ID;
(void)raftStoreWriteFile(pNode);
taosThreadMutexUnlock(&pNode->raftStore.mutex);
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
}
void raftStoreNextTerm(SSyncNode *pNode) {
taosThreadMutexLock(&pNode->raftStore.mutex);
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
pNode->raftStore.currentTerm++;
(void)raftStoreWriteFile(pNode);
taosThreadMutexUnlock(&pNode->raftStore.mutex);
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
}
void raftStoreSetTerm(SSyncNode *pNode, SyncTerm term) {
taosThreadMutexLock(&pNode->raftStore.mutex);
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
if (pNode->raftStore.currentTerm < term) {
pNode->raftStore.currentTerm = term;
(void)raftStoreWriteFile(pNode);
}
taosThreadMutexUnlock(&pNode->raftStore.mutex);
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
}
SyncTerm raftStoreGetTerm(SSyncNode *pNode) {
taosThreadMutexLock(&pNode->raftStore.mutex);
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
SyncTerm term = pNode->raftStore.currentTerm;
taosThreadMutexUnlock(&pNode->raftStore.mutex);
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
return term;
}