From f157c293ca9fc4b98487994845510f6067192baa Mon Sep 17 00:00:00 2001 From: amedama41 Date: Sun, 25 Oct 2015 16:28:13 +0900 Subject: [PATCH] Fix data loss when async_read_some is pending --- include/boost/asio/ssl/detail/io.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/boost/asio/ssl/detail/io.hpp b/include/boost/asio/ssl/detail/io.hpp index 2e889ec8..b0a99321 100644 --- a/include/boost/asio/ssl/detail/io.hpp +++ b/include/boost/asio/ssl/detail/io.hpp @@ -225,8 +225,18 @@ class io_op } default: - if (bytes_transferred == ~std::size_t(0)) + if (bytes_transferred == ~std::size_t(0)) { + if (want_ == engine::want_output) { + // Pass the result to the handler. + op_.call_handler(handler_, + core_.engine_.map_error_code(ec_), + ec_ ? 0 : bytes_transferred_); + return; + } bytes_transferred = 0; // Timer cancellation, no data transferred. + ec = boost::system::error_code(); + continue; + } else if (!ec_) ec_ = ec;