update return values
This commit is contained in:
parent
19819c4055
commit
5c8fef250c
|
@ -63,12 +63,12 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
|
||||||
pData->pWal = pSyncNode->pWal;
|
pData->pWal = pSyncNode->pWal;
|
||||||
ASSERT(pData->pWal != NULL);
|
ASSERT(pData->pWal != NULL);
|
||||||
|
|
||||||
taosThreadMutexInit(&(pData->mutex), NULL);
|
(void)taosThreadMutexInit(&(pData->mutex), NULL);
|
||||||
pData->pWalHandle = walOpenReader(pData->pWal, NULL, 0);
|
pData->pWalHandle = walOpenReader(pData->pWal, NULL, 0);
|
||||||
if (!pData->pWalHandle) {
|
if (!pData->pWalHandle) {
|
||||||
taosMemoryFree(pLogStore);
|
taosMemoryFree(pLogStore);
|
||||||
taosLRUCacheCleanup(pLogStore->pCache);
|
taosLRUCacheCleanup(pLogStore->pCache);
|
||||||
taosThreadMutexDestroy(&(pData->mutex));
|
(void)taosThreadMutexDestroy(&(pData->mutex));
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -96,13 +96,13 @@ void logStoreDestory(SSyncLogStore* pLogStore) {
|
||||||
if (pLogStore != NULL) {
|
if (pLogStore != NULL) {
|
||||||
SSyncLogStoreData* pData = pLogStore->data;
|
SSyncLogStoreData* pData = pLogStore->data;
|
||||||
|
|
||||||
taosThreadMutexLock(&(pData->mutex));
|
(void)taosThreadMutexLock(&(pData->mutex));
|
||||||
if (pData->pWalHandle != NULL) {
|
if (pData->pWalHandle != NULL) {
|
||||||
walCloseReader(pData->pWalHandle);
|
walCloseReader(pData->pWalHandle);
|
||||||
pData->pWalHandle = NULL;
|
pData->pWalHandle = NULL;
|
||||||
}
|
}
|
||||||
taosThreadMutexUnlock(&(pData->mutex));
|
(void)taosThreadMutexUnlock(&(pData->mutex));
|
||||||
taosThreadMutexDestroy(&(pData->mutex));
|
(void)taosThreadMutexDestroy(&(pData->mutex));
|
||||||
|
|
||||||
taosMemoryFree(pLogStore->data);
|
taosMemoryFree(pLogStore->data);
|
||||||
|
|
||||||
|
@ -261,12 +261,12 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
|
||||||
*ppEntry = NULL;
|
*ppEntry = NULL;
|
||||||
|
|
||||||
int64_t ts1 = taosGetTimestampNs();
|
int64_t ts1 = taosGetTimestampNs();
|
||||||
taosThreadMutexLock(&(pData->mutex));
|
(void)taosThreadMutexLock(&(pData->mutex));
|
||||||
|
|
||||||
SWalReader* pWalHandle = pData->pWalHandle;
|
SWalReader* pWalHandle = pData->pWalHandle;
|
||||||
if (pWalHandle == NULL) {
|
if (pWalHandle == NULL) {
|
||||||
sError("vgId:%d, wal handle is NULL", pData->pSyncNode->vgId);
|
sError("vgId:%d, wal handle is NULL", pData->pSyncNode->vgId);
|
||||||
taosThreadMutexUnlock(&(pData->mutex));
|
(void)taosThreadMutexUnlock(&(pData->mutex));
|
||||||
|
|
||||||
TAOS_RETURN(TSDB_CODE_SYN_INTERNAL_ERROR);
|
TAOS_RETURN(TSDB_CODE_SYN_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
|
||||||
terrno = saveErr;
|
terrno = saveErr;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
taosThreadMutexUnlock(&(pData->mutex));
|
(void)taosThreadMutexUnlock(&(pData->mutex));
|
||||||
|
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
|
||||||
(*ppEntry)->term = pWalHandle->pHead->head.syncMeta.term;
|
(*ppEntry)->term = pWalHandle->pHead->head.syncMeta.term;
|
||||||
(*ppEntry)->index = index;
|
(*ppEntry)->index = index;
|
||||||
ASSERT((*ppEntry)->dataLen == pWalHandle->pHead->head.bodyLen);
|
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;
|
int32_t saveErr = terrno;
|
||||||
|
@ -319,7 +319,7 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
|
||||||
terrno = saveErr;
|
terrno = saveErr;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
taosThreadMutexUnlock(&(pData->mutex));
|
(void)taosThreadMutexUnlock(&(pData->mutex));
|
||||||
int64_t ts4 = taosGetTimestampNs();
|
int64_t ts4 = taosGetTimestampNs();
|
||||||
|
|
||||||
int64_t tsElapsed = ts4 - ts1;
|
int64_t tsElapsed = ts4 - ts1;
|
||||||
|
|
|
@ -152,52 +152,52 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t raftStoreOpen(SSyncNode *pNode) {
|
int32_t raftStoreOpen(SSyncNode *pNode) {
|
||||||
taosThreadMutexInit(&pNode->raftStore.mutex, NULL);
|
(void)taosThreadMutexInit(&pNode->raftStore.mutex, NULL);
|
||||||
return raftStoreReadFile(pNode);
|
return raftStoreReadFile(pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void raftStoreClose(SSyncNode *pNode) { taosThreadMutexDestroy(&pNode->raftStore.mutex); }
|
void raftStoreClose(SSyncNode *pNode) { (void)taosThreadMutexDestroy(&pNode->raftStore.mutex); }
|
||||||
|
|
||||||
bool raftStoreHasVoted(SSyncNode *pNode) {
|
bool raftStoreHasVoted(SSyncNode *pNode) {
|
||||||
taosThreadMutexLock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
|
||||||
bool b = syncUtilEmptyId(&pNode->raftStore.voteFor);
|
bool b = syncUtilEmptyId(&pNode->raftStore.voteFor);
|
||||||
taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
||||||
return (!b);
|
return (!b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void raftStoreVote(SSyncNode *pNode, SRaftId *pRaftId) {
|
void raftStoreVote(SSyncNode *pNode, SRaftId *pRaftId) {
|
||||||
taosThreadMutexLock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
|
||||||
pNode->raftStore.voteFor = *pRaftId;
|
pNode->raftStore.voteFor = *pRaftId;
|
||||||
(void)raftStoreWriteFile(pNode);
|
(void)raftStoreWriteFile(pNode);
|
||||||
taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void raftStoreClearVote(SSyncNode *pNode) {
|
void raftStoreClearVote(SSyncNode *pNode) {
|
||||||
taosThreadMutexLock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
|
||||||
pNode->raftStore.voteFor = EMPTY_RAFT_ID;
|
pNode->raftStore.voteFor = EMPTY_RAFT_ID;
|
||||||
(void)raftStoreWriteFile(pNode);
|
(void)raftStoreWriteFile(pNode);
|
||||||
taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void raftStoreNextTerm(SSyncNode *pNode) {
|
void raftStoreNextTerm(SSyncNode *pNode) {
|
||||||
taosThreadMutexLock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
|
||||||
pNode->raftStore.currentTerm++;
|
pNode->raftStore.currentTerm++;
|
||||||
(void)raftStoreWriteFile(pNode);
|
(void)raftStoreWriteFile(pNode);
|
||||||
taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void raftStoreSetTerm(SSyncNode *pNode, SyncTerm term) {
|
void raftStoreSetTerm(SSyncNode *pNode, SyncTerm term) {
|
||||||
taosThreadMutexLock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
|
||||||
if (pNode->raftStore.currentTerm < term) {
|
if (pNode->raftStore.currentTerm < term) {
|
||||||
pNode->raftStore.currentTerm = term;
|
pNode->raftStore.currentTerm = term;
|
||||||
(void)raftStoreWriteFile(pNode);
|
(void)raftStoreWriteFile(pNode);
|
||||||
}
|
}
|
||||||
taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncTerm raftStoreGetTerm(SSyncNode *pNode) {
|
SyncTerm raftStoreGetTerm(SSyncNode *pNode) {
|
||||||
taosThreadMutexLock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexLock(&pNode->raftStore.mutex);
|
||||||
SyncTerm term = pNode->raftStore.currentTerm;
|
SyncTerm term = pNode->raftStore.currentTerm;
|
||||||
taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue