1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Fix possible thread race on sending packet from two threads

This commit is contained in:
Ivan Savenko
2024-02-25 20:05:28 +02:00
parent 8647abb94b
commit 6901945b6e
4 changed files with 4 additions and 2 deletions

View File

@@ -88,7 +88,6 @@ void NetworkConnection::sendPacket(const std::vector<std::byte> & message)
// create array with single element - boost::asio::buffer can be constructed from containers, but not from plain integer
std::array<uint32_t, 1> messageSize{static_cast<uint32_t>(message.size())};
boost::mutex::scoped_lock lock(writeMutex);
boost::asio::write(*socket, boost::asio::buffer(messageSize), ec );
boost::asio::write(*socket, boost::asio::buffer(message), ec );