From ad69207aba80f1dfc5b64ad4074a3903321842a5 Mon Sep 17 00:00:00 2001 From: Klemens Date: Tue, 1 Aug 2023 13:13:24 +0800 Subject: [PATCH] rebased. --- include/boost/async/io/detail/duplicate.hpp | 2 +- include/boost/async/io/result.hpp | 8 ++++---- include/boost/async/io/transfer_result.hpp | 4 ++-- src/io/datagram_socket.cpp | 2 +- src/io/detail/duplicate.cpp | 2 +- src/io/pipe.cpp | 8 ++++---- src/io/random_access_file.cpp | 2 +- src/io/seq_packet_socket.cpp | 2 +- src/io/serial_port.cpp | 2 +- src/io/ssl.cpp | 2 +- src/io/stream_file.cpp | 2 +- src/io/stream_socket.cpp | 2 +- test/io/ssl.cpp | 3 +-- 13 files changed, 20 insertions(+), 21 deletions(-) diff --git a/include/boost/async/io/detail/duplicate.hpp b/include/boost/async/io/detail/duplicate.hpp index c3b22d23..0f3451a6 100644 --- a/include/boost/async/io/detail/duplicate.hpp +++ b/include/boost/async/io/detail/duplicate.hpp @@ -12,7 +12,7 @@ #include #include -namespace boost::async::io::detail +namespace boost::async::detail::io { #if defined(BOOST_ASIO_WINDOWS) diff --git a/include/boost/async/io/result.hpp b/include/boost/async/io/result.hpp index f4092f41..b0b4cb6d 100644 --- a/include/boost/async/io/result.hpp +++ b/include/boost/async/io/result.hpp @@ -49,7 +49,7 @@ struct result_op auto & res = resource.emplace(buffer, sizeof(buffer), asio::get_associated_allocator(h.promise(), this_thread::get_allocator()).resource()); initiate(completion_handler{h, result, &res, &completed_immediately}); - return !completed_immediately; + return completed_immediately != detail::completed_immediately_t::yes; } catch(...) { @@ -94,7 +94,7 @@ struct result_op std::optional> result; char buffer[2048]; std::optional resource; - bool completed_immediately = false; + detail::completed_immediately_t completed_immediately = detail::completed_immediately_t::no; }; @@ -131,7 +131,7 @@ struct result_op auto & res = resource.emplace(buffer, sizeof(buffer), asio::get_associated_allocator(h.promise(), this_thread::get_allocator()).resource()); initiate(completion_handler{h, result, &res, &completed_immediately}); - return !completed_immediately; + return completed_immediately != detail::completed_immediately_t::yes; } catch(...) { @@ -178,7 +178,7 @@ struct result_op std::optional> result; char buffer[2048]; std::optional resource; - bool completed_immediately = false; + detail::completed_immediately_t completed_immediately = detail::completed_immediately_t::no; }; diff --git a/include/boost/async/io/transfer_result.hpp b/include/boost/async/io/transfer_result.hpp index ecf9a030..b17d6a1a 100644 --- a/include/boost/async/io/transfer_result.hpp +++ b/include/boost/async/io/transfer_result.hpp @@ -88,7 +88,7 @@ struct transfer_op auto & res = resource.emplace(buffer, sizeof(buffer), asio::get_associated_allocator(h.promise(), this_thread::get_allocator()).resource()); initiate(completion_handler{h, result, &res, &completed_immediately}); - return !completed_immediately; + return completed_immediately != detail::completed_immediately_t::yes; } catch(...) { @@ -131,7 +131,7 @@ struct transfer_op std::optional> result; char buffer[2048]; std::optional resource; - bool completed_immediately = false; + detail::completed_immediately_t completed_immediately = detail::completed_immediately_t::no; }; diff --git a/src/io/datagram_socket.cpp b/src/io/datagram_socket.cpp index 93cdfbcc..f4d13b1c 100644 --- a/src/io/datagram_socket.cpp +++ b/src/io/datagram_socket.cpp @@ -13,7 +13,7 @@ namespace boost::async::io system::result datagram_socket::duplicate() { - auto res = detail::duplicate_socket(datagram_socket_.native_handle()); + auto res = detail::io::duplicate_handle(datagram_socket_.native_handle()); if (!res) return res.error(); diff --git a/src/io/detail/duplicate.cpp b/src/io/detail/duplicate.cpp index 0db4a02e..08a80458 100644 --- a/src/io/detail/duplicate.cpp +++ b/src/io/detail/duplicate.cpp @@ -14,7 +14,7 @@ #include #endif -namespace boost::async::io::detail +namespace boost::async::detail::io { #if defined(BOOST_ASIO_WINDOWS) diff --git a/src/io/pipe.cpp b/src/io/pipe.cpp index 1bb67d9e..7c46cc26 100644 --- a/src/io/pipe.cpp +++ b/src/io/pipe.cpp @@ -49,7 +49,7 @@ void readable_pipe::async_write_some_impl_( system::error_code ec{asio::error::operation_not_supported, &loc}; if (h.completed_immediately) { - *h.completed_immediately = true; + *h.completed_immediately = detail::completed_immediately_t::maybe; h(ec, 0ul); } else @@ -75,7 +75,7 @@ auto readable_pipe::release() -> system::result system::result readable_pipe::duplicate() { - auto res = detail::duplicate_handle(pipe_.native_handle()); + auto res = detail::io::duplicate_handle(pipe_.native_handle()); if (!res) return res.error(); @@ -119,7 +119,7 @@ void writable_pipe::async_read_some_impl_( system::error_code ec{asio::error::operation_not_supported, &loc}; if (h.completed_immediately) { - *h.completed_immediately = true; + *h.completed_immediately = detail::completed_immediately_t::maybe; h(ec, 0ul); } else @@ -144,7 +144,7 @@ auto writable_pipe::release() -> system::result system::result writable_pipe::duplicate() { - auto res = detail::duplicate_handle(pipe_.native_handle()); + auto res = detail::io::duplicate_handle(pipe_.native_handle()); if (!res) return res.error(); diff --git a/src/io/random_access_file.cpp b/src/io/random_access_file.cpp index ba82a3ef..bdbbc363 100644 --- a/src/io/random_access_file.cpp +++ b/src/io/random_access_file.cpp @@ -15,7 +15,7 @@ namespace boost::async::io system::result random_access_file::duplicate() { - auto res = detail::duplicate_handle(random_access_file_.native_handle()); + auto res = detail::io::duplicate_handle(random_access_file_.native_handle()); if (!res) return res.error(); diff --git a/src/io/seq_packet_socket.cpp b/src/io/seq_packet_socket.cpp index 6b5ce858..c9651dff 100644 --- a/src/io/seq_packet_socket.cpp +++ b/src/io/seq_packet_socket.cpp @@ -13,7 +13,7 @@ namespace boost::async::io system::result seq_packet_socket::duplicate() { - auto res = detail::duplicate_socket(seq_packet_socket_.native_handle()); + auto res = detail::io::duplicate_handle(seq_packet_socket_.native_handle()); if (!res) return res.error(); diff --git a/src/io/serial_port.cpp b/src/io/serial_port.cpp index aa59c67f..25a3ebfd 100644 --- a/src/io/serial_port.cpp +++ b/src/io/serial_port.cpp @@ -145,7 +145,7 @@ auto serial_port::release() -> system::result } auto serial_port::duplicate() -> system::result { - auto fd = detail::duplicate_handle(serial_port_.native_handle()); + auto fd = detail::io::duplicate_handle(serial_port_.native_handle()); if (fd.has_error()) return fd.error(); return serial_port(*fd); diff --git a/src/io/ssl.cpp b/src/io/ssl.cpp index 882818b7..043f3866 100644 --- a/src/io/ssl.cpp +++ b/src/io/ssl.cpp @@ -15,7 +15,7 @@ namespace boost::async::io system::result ssl_stream::duplicate() { SSL_dup(ssl_stream_.native_handle()); - auto res = detail::duplicate_socket(ssl_stream_.native_handle()); + auto res = detail::io::duplicate_handle(ssl_stream_.native_handle()); if (!res) return res.error(); diff --git a/src/io/stream_file.cpp b/src/io/stream_file.cpp index 8a085346..2bb1c6e4 100644 --- a/src/io/stream_file.cpp +++ b/src/io/stream_file.cpp @@ -15,7 +15,7 @@ namespace boost::async::io system::result stream_file::duplicate() { - auto res = detail::duplicate_handle(stream_file_.native_handle()); + auto res = detail::io::duplicate_handle(stream_file_.native_handle()); if (!res) return res.error(); diff --git a/src/io/stream_socket.cpp b/src/io/stream_socket.cpp index 7f25b56c..7d96b8bf 100644 --- a/src/io/stream_socket.cpp +++ b/src/io/stream_socket.cpp @@ -13,7 +13,7 @@ namespace boost::async::io system::result stream_socket::duplicate() { - auto res = detail::duplicate_socket(stream_socket_.native_handle()); + auto res = detail::io::duplicate_handle(stream_socket_.native_handle()); if (!res) return res.error(); diff --git a/test/io/ssl.cpp b/test/io/ssl.cpp index bd03ba3f..fa5f37bc 100644 --- a/test/io/ssl.cpp +++ b/test/io/ssl.cpp @@ -16,7 +16,7 @@ CO_TEST_CASE("ssl") { using namespace boost; - asio::ssl::context ctx{asio::ssl::context_base::tlsv13_client}; + asio::ssl::context ctx{asio::ssl::context_base::tls_client}; auto t = (co_await async::io::lookup("boost.org", "https")).value(); REQUIRE(!t.empty()); @@ -26,6 +26,5 @@ CO_TEST_CASE("ssl") CHECK_MESSAGE(conn, conn.error().message()); CHECK_NOTHROW(co_await ss.async_handshake(async::io::ssl_stream::handshake_type::client).value()); - co_await ss.write_some("GET"); CHECK_NOTHROW(co_await ss.async_shutdown()); } \ No newline at end of file