Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
resetius committed Nov 28, 2023
1 parent 2c2b530 commit 20ce097
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ struct TCommandRequest: public TMessage {
char Data[0];
};

static_assert(sizeof(TCommandRequest) == sizeof(TMessage));

struct TCommandResponse: public TMessage {
static constexpr EMessageType MessageType = EMessageType::COMMAND_RESPONSE;
uint64_t Index;
};

static_assert(sizeof(TCommandResponse) == sizeof(TMessage) + 8);

struct TTimeout: public TMessage {
static constexpr EMessageType MessageType = EMessageType::TIMEOUT;
static constexpr std::chrono::milliseconds Election = std::chrono::milliseconds(5000);
Expand Down
5 changes: 3 additions & 2 deletions src/raft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ void TRaft::ApplyResult(ITimeSource::Time now, std::unique_ptr<TResult> result,
void TRaft::ProcessWaiting() {
auto commitIndex = VolatileState->CommitIndex;
while (!waiting.empty() && waiting.top().Index <= commitIndex) {
auto&& w = std::move(waiting.top()); waiting.pop();
w.ReplyTo->Send(std::move(w.Message));
auto w = waiting.top(); waiting.pop();
w.ReplyTo->Send(w.Message);
}
}

0 comments on commit 20ce097

Please sign in to comment.