From e28c0d9b1072c8b75ed43c09f883b1a0bd06846d Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Fri, 21 Oct 2016 19:00:03 +0200 Subject: Only send one transaction at a time when 2 async_sends are queued after each other. --- libcmix-network/client.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libcmix-network') diff --git a/libcmix-network/client.hpp b/libcmix-network/client.hpp index 0b98c1c..2501908 100644 --- a/libcmix-network/client.hpp +++ b/libcmix-network/client.hpp @@ -152,17 +152,19 @@ public: os.write(reinterpret_cast(length_buffer.data()), length_buffer.size()); os.write(message.data(), message.size()); - auto handler = [on_sent](boost::system::error_code const& ec, std::size_t bytes_transferred) { + auto handler = [this, on_sent](boost::system::error_code const& ec, std::size_t bytes_transferred) { if(ec) { BOOST_LOG_TRIVIAL(fatal) << ec.message(); throw std::runtime_error("unable to send message"); } + send_buffer->consume(bytes_transferred); on_sent(); }; + boost::asio::async_write( *socket, - *send_buffer, + send_buffer->data(), handler ); } -- cgit v1.2.3-70-g09d2