提交 6729c130 编写于 作者: B Benguang Zhao

fix: leave some free space in log buffer during syncLogBufferInit

上级 22d64b9c
...@@ -182,7 +182,8 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) { ...@@ -182,7 +182,8 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
} }
bool taken = false; bool taken = false;
if (toIndex <= index + pBuf->size - 1) { int emptySize = 5;
if (toIndex - index + 1 <= pBuf->size - emptySize) {
SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = -1, .prevLogTerm = -1}; SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = -1, .prevLogTerm = -1};
pBuf->entries[index % pBuf->size] = tmp; pBuf->entries[index % pBuf->size] = tmp;
taken = true; taken = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册