From d0cf40d5b206a3aa29e9eb3c3f31ad7bc85b930a Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Tue, 26 Feb 2019 12:36:03 -0800 Subject: [PATCH] Fix as-if post --- include/boost/beast/core/detail/impl/read.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/boost/beast/core/detail/impl/read.hpp b/include/boost/beast/core/detail/impl/read.hpp index c237ce20..74458ed2 100644 --- a/include/boost/beast/core/detail/impl/read.hpp +++ b/include/boost/beast/core/detail/impl/read.hpp @@ -73,14 +73,13 @@ public: std::size_t bytes_transferred, bool cont = true) { - ec_ = ec; std::size_t max_size; std::size_t max_prepare; BOOST_ASIO_CORO_REENTER(*this) { for(;;) { - max_size = cond_(ec_, total_, b_); + max_size = cond_(ec, total_, b_); max_prepare = std::min( std::max( 512, b_.capacity() - b_.size()), @@ -98,11 +97,13 @@ public: { // run this handler "as-if" using net::post // to reduce template instantiations + ec_ = ec; BOOST_ASIO_CORO_YIELD s_.async_read_some( b_.prepare(0), std::move(*this)); + ec = ec_; } - this->invoke_now(ec_, total_); + this->invoke_now(ec, total_); } } };