Skip to content

Commit

Permalink
Move crypto calculations to asio thread (#4802)
Browse files Browse the repository at this point in the history
* Move crypto calculations to asio thread

* Update src/connection.cpp

Co-authored-by: Ranieri Althoff <1993083+ranisalt@users.noreply.github.com>

---------

Co-authored-by: Ranieri Althoff <1993083+ranisalt@users.noreply.github.com>
  • Loading branch information
nekiro and ranisalt authored Oct 8, 2024
1 parent 6a2e060 commit 7d3baac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,14 @@ void Connection::send(const OutputMessage_ptr& msg)
bool noPendingWrite = messageQueue.empty();
messageQueue.emplace_back(msg);
if (noPendingWrite) {
internalSend(msg);
try {
boost::asio::post(socket.get_executor(),
[thisPtr = shared_from_this(), msg] { thisPtr->internalSend(msg); });
} catch (const boost::system::system_error& e) {
std::cout << "[Network error - Connection::send] " << e.what() << std::endl;
messageQueue.clear();
close(FORCE_CLOSE);
}
}
}

Expand Down

0 comments on commit 7d3baac

Please sign in to comment.