Skip to content

Commit

Permalink
Better drain
Browse files Browse the repository at this point in the history
  • Loading branch information
resetius committed Dec 1, 2023
1 parent aa48e7e commit 9245b3e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,17 @@ void TNode<TPoller>::Drain() {

template<typename TPoller>
NNet::TTestTask TNode<TPoller>::DoDrain() {
auto tosend = std::move(Messages);
try {
for (auto&& m : tosend) {
co_await TWriter(Socket).Write(std::move(m));
while (!Messages.empty()) {
auto tosend = std::move(Messages); Messages.clear();
for (auto&& m : tosend) {
co_await TWriter(Socket).Write(std::move(m));
}
}
} catch (const std::exception& ex) {
std::cout << "Error on write: " << ex.what() << "\n";
Connect();
}
Messages.clear();
co_return;
}

Expand Down

0 comments on commit 9245b3e

Please sign in to comment.