summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/include/asio/ssl/detail/io.hpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/include/asio/ssl/detail/io.hpp')
-rw-r--r--3rdparty/asio/include/asio/ssl/detail/io.hpp123
1 files changed, 88 insertions, 35 deletions
diff --git a/3rdparty/asio/include/asio/ssl/detail/io.hpp b/3rdparty/asio/include/asio/ssl/detail/io.hpp
index 5d35ba45707..b8c85dc6b53 100644
--- a/3rdparty/asio/include/asio/ssl/detail/io.hpp
+++ b/3rdparty/asio/include/asio/ssl/detail/io.hpp
@@ -2,7 +2,7 @@
// ssl/detail/io.hpp
// ~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -17,6 +17,8 @@
#include "asio/detail/config.hpp"
+#include "asio/detail/base_from_cancellation_state.hpp"
+#include "asio/detail/handler_tracking.hpp"
#include "asio/ssl/detail/engine.hpp"
#include "asio/ssl/detail/stream_core.hpp"
#include "asio/write.hpp"
@@ -31,6 +33,7 @@ template <typename Stream, typename Operation>
std::size_t io(Stream& next_layer, stream_core& core,
const Operation& op, asio::error_code& ec)
{
+ asio::error_code io_ec;
std::size_t bytes_transferred = 0;
do switch (op(core.engine_, ec, bytes_transferred))
{
@@ -39,8 +42,12 @@ std::size_t io(Stream& next_layer, stream_core& core,
// If the input buffer is empty then we need to read some more data from
// the underlying transport.
if (core.input_.size() == 0)
+ {
core.input_ = asio::buffer(core.input_buffer_,
- next_layer.read_some(core.input_buffer_, ec));
+ next_layer.read_some(core.input_buffer_, io_ec));
+ if (!ec)
+ ec = io_ec;
+ }
// Pass the new input data to the engine.
core.input_ = core.engine_.put_input(core.input_);
@@ -53,7 +60,9 @@ std::size_t io(Stream& next_layer, stream_core& core,
// Get output data from the engine and write it to the underlying
// transport.
asio::write(next_layer,
- core.engine_.get_output(core.output_buffer_), ec);
+ core.engine_.get_output(core.output_buffer_), io_ec);
+ if (!ec)
+ ec = io_ec;
// Try the operation again.
continue;
@@ -63,7 +72,9 @@ std::size_t io(Stream& next_layer, stream_core& core,
// Get output data from the engine and write it to the underlying
// transport.
asio::write(next_layer,
- core.engine_.get_output(core.output_buffer_), ec);
+ core.engine_.get_output(core.output_buffer_), io_ec);
+ if (!ec)
+ ec = io_ec;
// Operation is complete. Return result to caller.
core.engine_.map_error_code(ec);
@@ -84,11 +95,13 @@ std::size_t io(Stream& next_layer, stream_core& core,
template <typename Stream, typename Operation, typename Handler>
class io_op
+ : public asio::detail::base_from_cancellation_state<Handler>
{
public:
io_op(Stream& next_layer, stream_core& core,
const Operation& op, Handler& handler)
- : next_layer_(next_layer),
+ : asio::detail::base_from_cancellation_state<Handler>(handler),
+ next_layer_(next_layer),
core_(core),
op_(op),
start_(0),
@@ -100,7 +113,8 @@ public:
#if defined(ASIO_HAS_MOVE)
io_op(const io_op& other)
- : next_layer_(other.next_layer_),
+ : asio::detail::base_from_cancellation_state<Handler>(other),
+ next_layer_(other.next_layer_),
core_(other.core_),
op_(other.op_),
start_(other.start_),
@@ -112,9 +126,13 @@ public:
}
io_op(io_op&& other)
- : next_layer_(other.next_layer_),
+ : asio::detail::base_from_cancellation_state<Handler>(
+ ASIO_MOVE_CAST(
+ asio::detail::base_from_cancellation_state<Handler>)(
+ other)),
+ next_layer_(other.next_layer_),
core_(other.core_),
- op_(other.op_),
+ op_(ASIO_MOVE_CAST(Operation)(other.op_)),
start_(other.start_),
want_(other.want_),
ec_(other.ec_),
@@ -153,6 +171,9 @@ public:
// Prevent other read operations from being started.
core_.pending_read_.expires_at(core_.pos_infin());
+ ASIO_HANDLER_LOCATION((
+ __FILE__, __LINE__, Operation::tracking_name()));
+
// Start reading some data from the underlying transport.
next_layer_.async_read_some(
asio::buffer(core_.input_buffer_),
@@ -160,6 +181,9 @@ public:
}
else
{
+ ASIO_HANDLER_LOCATION((
+ __FILE__, __LINE__, Operation::tracking_name()));
+
// Wait until the current read operation completes.
core_.pending_read_.async_wait(ASIO_MOVE_CAST(io_op)(*this));
}
@@ -180,6 +204,9 @@ public:
// Prevent other write operations from being started.
core_.pending_write_.expires_at(core_.pos_infin());
+ ASIO_HANDLER_LOCATION((
+ __FILE__, __LINE__, Operation::tracking_name()));
+
// Start writing all the data to the underlying transport.
asio::async_write(next_layer_,
core_.engine_.get_output(core_.output_buffer_),
@@ -187,6 +214,9 @@ public:
}
else
{
+ ASIO_HANDLER_LOCATION((
+ __FILE__, __LINE__, Operation::tracking_name()));
+
// Wait until the current write operation completes.
core_.pending_write_.async_wait(ASIO_MOVE_CAST(io_op)(*this));
}
@@ -204,6 +234,9 @@ public:
// read so the handler runs "as-if" posted using io_context::post().
if (start)
{
+ ASIO_HANDLER_LOCATION((
+ __FILE__, __LINE__, Operation::tracking_name()));
+
next_layer_.async_read_some(
asio::buffer(core_.input_buffer_, 0),
ASIO_MOVE_CAST(io_op)(*this));
@@ -237,6 +270,13 @@ public:
// Release any waiting read operations.
core_.pending_read_.expires_at(core_.neg_infin());
+ // Check for cancellation before continuing.
+ if (this->cancelled() != cancellation_type::none)
+ {
+ ec_ = asio::error::operation_aborted;
+ break;
+ }
+
// Try the operation again.
continue;
@@ -245,6 +285,13 @@ public:
// Release any waiting write operations.
core_.pending_write_.expires_at(core_.neg_infin());
+ // Check for cancellation before continuing.
+ if (this->cancelled() != cancellation_type::none)
+ {
+ ec_ = asio::error::operation_aborted;
+ break;
+ }
+
// Try the operation again.
continue;
@@ -284,19 +331,29 @@ public:
};
template <typename Stream, typename Operation, typename Handler>
-inline void* asio_handler_allocate(std::size_t size,
+inline asio_handler_allocate_is_deprecated
+asio_handler_allocate(std::size_t size,
io_op<Stream, Operation, Handler>* this_handler)
{
+#if defined(ASIO_NO_DEPRECATED)
+ asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
+ return asio_handler_allocate_is_no_longer_used();
+#else // defined(ASIO_NO_DEPRECATED)
return asio_handler_alloc_helpers::allocate(
size, this_handler->handler_);
+#endif // defined(ASIO_NO_DEPRECATED)
}
template <typename Stream, typename Operation, typename Handler>
-inline void asio_handler_deallocate(void* pointer, std::size_t size,
+inline asio_handler_deallocate_is_deprecated
+asio_handler_deallocate(void* pointer, std::size_t size,
io_op<Stream, Operation, Handler>* this_handler)
{
asio_handler_alloc_helpers::deallocate(
pointer, size, this_handler->handler_);
+#if defined(ASIO_NO_DEPRECATED)
+ return asio_handler_deallocate_is_no_longer_used();
+#endif // defined(ASIO_NO_DEPRECATED)
}
template <typename Stream, typename Operation, typename Handler>
@@ -309,20 +366,28 @@ inline bool asio_handler_is_continuation(
template <typename Function, typename Stream,
typename Operation, typename Handler>
-inline void asio_handler_invoke(Function& function,
+inline asio_handler_invoke_is_deprecated
+asio_handler_invoke(Function& function,
io_op<Stream, Operation, Handler>* this_handler)
{
asio_handler_invoke_helpers::invoke(
function, this_handler->handler_);
+#if defined(ASIO_NO_DEPRECATED)
+ return asio_handler_invoke_is_no_longer_used();
+#endif // defined(ASIO_NO_DEPRECATED)
}
template <typename Function, typename Stream,
typename Operation, typename Handler>
-inline void asio_handler_invoke(const Function& function,
+inline asio_handler_invoke_is_deprecated
+asio_handler_invoke(const Function& function,
io_op<Stream, Operation, Handler>* this_handler)
{
asio_handler_invoke_helpers::invoke(
function, this_handler->handler_);
+#if defined(ASIO_NO_DEPRECATED)
+ return asio_handler_invoke_is_no_longer_used();
+#endif // defined(ASIO_NO_DEPRECATED)
}
template <typename Stream, typename Operation, typename Handler>
@@ -337,31 +402,19 @@ inline void async_io(Stream& next_layer, stream_core& core,
} // namespace detail
} // namespace ssl
-template <typename Stream, typename Operation,
- typename Handler, typename Allocator>
-struct associated_allocator<
- ssl::detail::io_op<Stream, Operation, Handler>, Allocator>
+template <template <typename, typename> class Associator,
+ typename Stream, typename Operation,
+ typename Handler, typename DefaultCandidate>
+struct associator<Associator,
+ ssl::detail::io_op<Stream, Operation, Handler>,
+ DefaultCandidate>
+ : Associator<Handler, DefaultCandidate>
{
- typedef typename associated_allocator<Handler, Allocator>::type type;
-
- static type get(const ssl::detail::io_op<Stream, Operation, Handler>& h,
- const Allocator& a = Allocator()) ASIO_NOEXCEPT
- {
- return associated_allocator<Handler, Allocator>::get(h.handler_, a);
- }
-};
-
-template <typename Stream, typename Operation,
- typename Handler, typename Executor>
-struct associated_executor<
- ssl::detail::io_op<Stream, Operation, Handler>, Executor>
-{
- typedef typename associated_executor<Handler, Executor>::type type;
-
- static type get(const ssl::detail::io_op<Stream, Operation, Handler>& h,
- const Executor& ex = Executor()) ASIO_NOEXCEPT
+ static typename Associator<Handler, DefaultCandidate>::type get(
+ const ssl::detail::io_op<Stream, Operation, Handler>& h,
+ const DefaultCandidate& c = DefaultCandidate()) ASIO_NOEXCEPT
{
- return associated_executor<Handler, Executor>::get(h.handler_, ex);
+ return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
}
};