forked from boostorg/beast
beast support per-op cancellation
- websocket supports cancellation. - Iterating test for ws cancellation. - Only terminal cancellation is forwarded by default. - basic_stream supports cancellation. - supported cancellation is documented. - http cancellation additions. - Added cancellation_slot tests to http, utils and saved_handler. - Added post to write.cpp, to avoid SIGSEV in test. - Refresher describes cancellation in more detail.
This commit is contained in:
committed by
Klemens Morgenstern
parent
0bf3d971a0
commit
3ebff60b1a
@@ -178,8 +178,18 @@ class write_op
|
||||
Stream& s_;
|
||||
serializer<isRequest, Body, Fields>& sr_;
|
||||
std::size_t bytes_transferred_ = 0;
|
||||
net::cancellation_state st_{this->
|
||||
beast::async_base<Handler, beast::executor_type<Stream>>
|
||||
::get_cancellation_slot()};
|
||||
|
||||
public:
|
||||
using cancellation_slot_type = net::cancellation_slot;
|
||||
cancellation_slot_type get_cancellation_slot() const noexcept
|
||||
{
|
||||
return st_.slot();
|
||||
}
|
||||
|
||||
|
||||
template<class Handler_>
|
||||
write_op(
|
||||
Handler_&& h,
|
||||
@@ -227,6 +237,8 @@ public:
|
||||
s_, sr_, std::move(*this));
|
||||
}
|
||||
bytes_transferred_ += bytes_transferred;
|
||||
if (!ec && st_.cancelled() != net::cancellation_type::none)
|
||||
ec = net::error::operation_aborted;
|
||||
if(ec)
|
||||
goto upcall;
|
||||
if(Predicate{}(sr_))
|
||||
|
||||
@@ -200,6 +200,19 @@ read_some(
|
||||
@note The completion handler will receive as a parameter the total number
|
||||
of bytes transferred from the stream. This may be zero for the case where
|
||||
there is sufficient pre-existing message data in the dynamic buffer.
|
||||
|
||||
@par Per-Operation Cancellation
|
||||
|
||||
This asynchronous operation supports cancellation for the following
|
||||
net::cancellation_type values:
|
||||
|
||||
@li @c net::cancellation_type::terminal
|
||||
|
||||
if the `stream` also supports terminal cancellation.
|
||||
|
||||
`terminal` cancellation leaves the stream in an undefined state,
|
||||
so that only closing it is guaranteed to succeed.
|
||||
|
||||
*/
|
||||
template<
|
||||
class AsyncReadStream,
|
||||
@@ -397,6 +410,19 @@ read_header(
|
||||
there is sufficient pre-existing message data in the dynamic buffer. The
|
||||
implementation will call @ref basic_parser::eager with the value `false`
|
||||
on the parser passed in.
|
||||
|
||||
@par Per-Operation Cancellation
|
||||
|
||||
This asynchronous operation supports cancellation for the following
|
||||
net::cancellation_type values:
|
||||
|
||||
@li @c net::cancellation_type::terminal
|
||||
|
||||
if the `stream` also supports terminal cancellation.
|
||||
|
||||
`terminal` cancellation leaves the stream in an undefined state,
|
||||
so that only closing it is guaranteed to succeed.
|
||||
|
||||
*/
|
||||
template<
|
||||
class AsyncReadStream,
|
||||
@@ -594,6 +620,19 @@ read(
|
||||
there is sufficient pre-existing message data in the dynamic buffer. The
|
||||
implementation will call @ref basic_parser::eager with the value `true`
|
||||
on the parser passed in.
|
||||
|
||||
@par Per-Operation Cancellation
|
||||
|
||||
This asynchronous operation supports cancellation for the following
|
||||
net::cancellation_type values:
|
||||
|
||||
@li @c net::cancellation_type::terminal
|
||||
|
||||
if the `stream` also supports terminal cancellation.
|
||||
|
||||
`terminal` cancellation leaves the stream in an undefined state,
|
||||
so that only closing it is guaranteed to succeed.
|
||||
|
||||
*/
|
||||
template<
|
||||
class AsyncReadStream,
|
||||
@@ -800,6 +839,19 @@ read(
|
||||
there is sufficient pre-existing message data in the dynamic buffer. The
|
||||
implementation will call @ref basic_parser::eager with the value `true`
|
||||
on the parser passed in.
|
||||
|
||||
@par Per-Operation Cancellation
|
||||
|
||||
This asynchronous operation supports cancellation for the following
|
||||
net::cancellation_type values:
|
||||
|
||||
@li @c net::cancellation_type::terminal
|
||||
|
||||
if the `stream` also supports terminal cancellation.
|
||||
|
||||
`terminal` cancellation leaves the stream in an undefined state,
|
||||
so that only closing it is guaranteed to succeed.
|
||||
|
||||
*/
|
||||
template<
|
||||
class AsyncReadStream,
|
||||
|
||||
@@ -161,6 +161,18 @@ write_some(
|
||||
this function. Invocation of the handler will be performed in a
|
||||
manner equivalent to using `net::post`.
|
||||
|
||||
@par Per-Operation Cancellation
|
||||
|
||||
This asynchronous operation supports cancellation for the following
|
||||
net::cancellation_type values:
|
||||
|
||||
@li @c net::cancellation_type::terminal
|
||||
|
||||
if the `stream` also supports terminal cancellation.
|
||||
|
||||
`terminal` cancellation leaves the stream in an undefined state,
|
||||
so that only closing it is guaranteed to succeed.
|
||||
|
||||
@see serializer
|
||||
*/
|
||||
template<
|
||||
@@ -291,6 +303,18 @@ write_header(
|
||||
@note The implementation will call @ref serializer::split with
|
||||
the value `true` on the serializer passed in.
|
||||
|
||||
@par Per-Operation Cancellation
|
||||
|
||||
This asynchronous operation supports cancellation for the following
|
||||
net::cancellation_type values:
|
||||
|
||||
@li @c net::cancellation_type::terminal
|
||||
|
||||
if the `stream` also supports terminal cancellation.
|
||||
|
||||
`terminal` cancellation leaves the stream in an undefined state,
|
||||
so that only closing it is guaranteed to succeed.
|
||||
|
||||
@see serializer
|
||||
*/
|
||||
template<
|
||||
@@ -412,6 +436,18 @@ write(
|
||||
this function. Invocation of the handler will be performed in a
|
||||
manner equivalent to using `net::post`.
|
||||
|
||||
@par Per-Operation Cancellation
|
||||
|
||||
This asynchronous operation supports cancellation for the following
|
||||
net::cancellation_type values:
|
||||
|
||||
@li @c net::cancellation_type::terminal
|
||||
|
||||
if the `stream` also supports terminal cancellation.
|
||||
|
||||
`terminal` cancellation leaves the stream in an undefined state,
|
||||
so that only closing it is guaranteed to succeed.
|
||||
|
||||
@see serializer
|
||||
*/
|
||||
template<
|
||||
@@ -637,6 +673,18 @@ write(
|
||||
this function. Invocation of the handler will be performed in a
|
||||
manner equivalent to using `net::post`.
|
||||
|
||||
@par Per-Operation Cancellation
|
||||
|
||||
This asynchronous operation supports cancellation for the following
|
||||
net::cancellation_type values:
|
||||
|
||||
@li @c net::cancellation_type::terminal
|
||||
|
||||
if the `stream` also supports terminal cancellation.
|
||||
|
||||
`terminal` cancellation leaves the stream in an undefined state,
|
||||
so that only closing it is guaranteed to succeed.
|
||||
|
||||
@see message
|
||||
*/
|
||||
template<
|
||||
@@ -699,6 +747,18 @@ async_write(
|
||||
this function. Invocation of the handler will be performed in a
|
||||
manner equivalent to using `net::post`.
|
||||
|
||||
@par Per-Operation Cancellation
|
||||
|
||||
This asynchronous operation supports cancellation for the following
|
||||
net::cancellation_type values:
|
||||
|
||||
@li @c net::cancellation_type::terminal
|
||||
|
||||
if the `stream` also supports terminal cancellation.
|
||||
|
||||
`terminal` cancellation leaves the stream in an undefined state,
|
||||
so that only closing it is guaranteed to succeed.
|
||||
|
||||
@see message
|
||||
*/
|
||||
template<
|
||||
|
||||
Reference in New Issue
Block a user