Commit af1f91ba authored by Dominik Charousset's avatar Dominik Charousset

fixed serialization

parent d2093555
...@@ -253,7 +253,13 @@ class peer_connection : public network_channel { ...@@ -253,7 +253,13 @@ class peer_connection : public network_channel {
void write(const addressed_message& msg) { void write(const addressed_message& msg) {
binary_serializer bs(&m_wr_buf); binary_serializer bs(&m_wr_buf);
std::uint32_t size = 0;
auto before = m_wr_buf.size();
m_wr_buf.write(sizeof(std::uint32_t), &size, util::grow_if_needed);
bs << msg; bs << msg;
size = m_wr_buf.size() - sizeof(std::uint32_t);
// update size in buffer
memcpy(m_wr_buf.data() + before, &size, sizeof(std::uint32_t));
if (!has_unwritten_data()) { if (!has_unwritten_data()) {
size_t written = m_ostream->write_some(m_wr_buf.data(), size_t written = m_ostream->write_some(m_wr_buf.data(),
m_wr_buf.size()); m_wr_buf.size());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment