From fc1b01e27c73fcd62056f4247d6db803ec183d53 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Mon, 1 Dec 2025 22:49:32 +1100 Subject: [PATCH] Ensure sync SSL shutdown remaps error::eof as async_shutdown does. --- .../boost/asio/ssl/detail/buffered_handshake_op.hpp | 4 ++++ include/boost/asio/ssl/detail/handshake_op.hpp | 4 ++++ include/boost/asio/ssl/detail/io.hpp | 3 +++ include/boost/asio/ssl/detail/read_op.hpp | 4 ++++ include/boost/asio/ssl/detail/shutdown_op.hpp | 11 +++++++++++ include/boost/asio/ssl/detail/write_op.hpp | 4 ++++ 6 files changed, 30 insertions(+) diff --git a/include/boost/asio/ssl/detail/buffered_handshake_op.hpp b/include/boost/asio/ssl/detail/buffered_handshake_op.hpp index adf6f904..0023d512 100644 --- a/include/boost/asio/ssl/detail/buffered_handshake_op.hpp +++ b/include/boost/asio/ssl/detail/buffered_handshake_op.hpp @@ -52,6 +52,10 @@ public: boost::asio::buffer_sequence_end(buffers_)); } + void complete_sync(boost::system::error_code&) const + { + } + template void call_handler(Handler& handler, const boost::system::error_code& ec, diff --git a/include/boost/asio/ssl/detail/handshake_op.hpp b/include/boost/asio/ssl/detail/handshake_op.hpp index 8754ed7d..6816502a 100644 --- a/include/boost/asio/ssl/detail/handshake_op.hpp +++ b/include/boost/asio/ssl/detail/handshake_op.hpp @@ -47,6 +47,10 @@ public: return eng.handshake(type_, ec); } + void complete_sync(boost::system::error_code&) const + { + } + template void call_handler(Handler& handler, const boost::system::error_code& ec, diff --git a/include/boost/asio/ssl/detail/io.hpp b/include/boost/asio/ssl/detail/io.hpp index 4052b529..5fd723a8 100644 --- a/include/boost/asio/ssl/detail/io.hpp +++ b/include/boost/asio/ssl/detail/io.hpp @@ -79,18 +79,21 @@ std::size_t io(Stream& next_layer, stream_core& core, // Operation is complete. Return result to caller. core.engine_.map_error_code(ec); + op.complete_sync(ec); return bytes_transferred; default: // Operation is complete. Return result to caller. core.engine_.map_error_code(ec); + op.complete_sync(ec); return bytes_transferred; } while (!ec); // Operation failed. Return result to caller. core.engine_.map_error_code(ec); + op.complete_sync(ec); return 0; } diff --git a/include/boost/asio/ssl/detail/read_op.hpp b/include/boost/asio/ssl/detail/read_op.hpp index ef93709e..f75f131f 100644 --- a/include/boost/asio/ssl/detail/read_op.hpp +++ b/include/boost/asio/ssl/detail/read_op.hpp @@ -52,6 +52,10 @@ public: return eng.read(buffer, ec, bytes_transferred); } + void complete_sync(boost::system::error_code&) const + { + } + template void call_handler(Handler& handler, const boost::system::error_code& ec, diff --git a/include/boost/asio/ssl/detail/shutdown_op.hpp b/include/boost/asio/ssl/detail/shutdown_op.hpp index 8f632f5b..ec5d6566 100644 --- a/include/boost/asio/ssl/detail/shutdown_op.hpp +++ b/include/boost/asio/ssl/detail/shutdown_op.hpp @@ -42,6 +42,17 @@ public: return eng.shutdown(ec); } + void complete_sync(boost::system::error_code& ec) const + { + if (ec == boost::asio::error::eof) + { + // The engine only generates an eof when the shutdown notification has + // been received from the peer. This indicates that the shutdown has + // completed successfully, and thus need not be returned to the caller. + ec = boost::system::error_code(); + } + } + template void call_handler(Handler& handler, const boost::system::error_code& ec, diff --git a/include/boost/asio/ssl/detail/write_op.hpp b/include/boost/asio/ssl/detail/write_op.hpp index 8cd3463d..83a2a885 100644 --- a/include/boost/asio/ssl/detail/write_op.hpp +++ b/include/boost/asio/ssl/detail/write_op.hpp @@ -56,6 +56,10 @@ public: return eng.write(buffer, ec, bytes_transferred); } + void complete_sync(boost::system::error_code&) const + { + } + template void call_handler(Handler& handler, const boost::system::error_code& ec,