Skip to content

Commit

Permalink
Speedup forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
resetius committed Dec 25, 2024
1 parent 6d2f912 commit 6e205b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,21 @@ template<typename TSocket>
NNet::TVoidTask TRaftServer<TSocket>::OutboundServe(std::shared_ptr<TNode<TSocket>> node) {
// read forwarded replies
while (true) {
bool error = false;
try {
auto mes = co_await TMessageReader(node->Sock()).Read();
// TODO: check message type
// TODO: should be only TCommandResponse
Raft->Process(TimeSource->Now(), std::move(mes), nullptr);
DrainNodes();
} catch (const std::exception& ex) {
// wait for reconnection
std::cerr << "Exception: " << ex.what() << "\n";
error = true;
}
if (error) {
co_await Poller.Sleep(std::chrono::milliseconds(1000));
}
co_await Poller.Sleep(std::chrono::milliseconds(1000));
}
co_return;
}
Expand Down

0 comments on commit 6e205b9

Please sign in to comment.