Permalink
Browse files

fixed serialization

  • Loading branch information...
1 parent d209355 commit af1f91bae9f1dc6177409f01afbfbaa162f093cb @Neverlord Neverlord committed Aug 27, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/middleman.cpp
View
@@ -253,7 +253,13 @@ class peer_connection : public network_channel {
void write(const addressed_message& msg) {
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;
+ 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()) {
size_t written = m_ostream->write_some(m_wr_buf.data(),
m_wr_buf.size());

0 comments on commit af1f91b

Please sign in to comment.