From 5b46cbefe9f7506540e1bcc479d6808a58889650 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 12 Nov 2022 15:24:49 +0800 Subject: [PATCH] enh: adjust request vote reply --- source/libs/sync/inc/syncMessage.h | 11 ----------- source/libs/sync/src/syncMain.c | 2 +- source/libs/sync/src/syncRequestVote.c | 2 +- source/libs/sync/test/sync_test_lib/inc/syncBatch.h | 9 +++++++++ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/source/libs/sync/inc/syncMessage.h b/source/libs/sync/inc/syncMessage.h index 663427cf20..25bf097faf 100644 --- a/source/libs/sync/inc/syncMessage.h +++ b/source/libs/sync/inc/syncMessage.h @@ -115,17 +115,6 @@ void syncAppendEntriesPrint2(char* s, const SyncAppendEntries* pMsg); void syncAppendEntriesLog(const SyncAppendEntries* pMsg); void syncAppendEntriesLog2(char* s, const SyncAppendEntries* pMsg); -// --------------------------------------------- - -typedef struct SOffsetAndContLen { - int32_t offset; - int32_t contLen; -} SOffsetAndContLen; - -// data: -// block1: SOffsetAndContLen Array -// block2: entry Array - typedef struct SyncAppendEntriesReply { uint32_t bytes; int32_t vgId; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 6e8a927e3f..636bf9410e 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -1654,7 +1654,7 @@ void syncNodeVoteForSelf(SSyncNode* pSyncNode) { SRpcMsg rpcMsg = {0}; int32_t ret = syncBuildRequestVoteReply(&rpcMsg, pSyncNode->vgId); - if (ret == 0) return; + if (ret != 0) return; SyncRequestVoteReply* pMsg = rpcMsg.pCont; pMsg->srcId = pSyncNode->myRaftId; diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index 9085572ebe..e2cce28671 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -141,7 +141,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { // send msg SRpcMsg rpcMsg = {0}; ret = syncBuildRequestVoteReply(&rpcMsg, ths->vgId); - ASSERT(ret); + ASSERT(ret == 0 ); SyncRequestVoteReply* pReply = rpcMsg.pCont; pReply->srcId = ths->myRaftId; diff --git a/source/libs/sync/test/sync_test_lib/inc/syncBatch.h b/source/libs/sync/test/sync_test_lib/inc/syncBatch.h index 8d8859fc1f..9ea9da8d69 100644 --- a/source/libs/sync/test/sync_test_lib/inc/syncBatch.h +++ b/source/libs/sync/test/sync_test_lib/inc/syncBatch.h @@ -58,6 +58,15 @@ void syncClientRequestBatchPrint2(char* s, const SyncClientRequestBatch* pMsg); void syncClientRequestBatchLog(const SyncClientRequestBatch* pMsg); void syncClientRequestBatchLog2(char* s, const SyncClientRequestBatch* pMsg); +typedef struct SOffsetAndContLen { + int32_t offset; + int32_t contLen; +} SOffsetAndContLen; + +// data: +// block1: SOffsetAndContLen Array +// block2: entry Array + typedef struct SyncAppendEntriesBatch { uint32_t bytes; int32_t vgId;