Skip to content

Commit

Permalink
burl: enable cancellation in any_stream and async_request
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtum committed Dec 31, 2024
1 parent a6031d7 commit b028cd0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
12 changes: 8 additions & 4 deletions example/client/burl/any_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,21 @@ class any_stream
{
BOOST_ASIO_CORO_REENTER(c)
{
self.reset_cancellation_state(
asio::enable_total_cancellation{});
if(wr_remain_ == 0)
{
wr_timer.expires_after(std::chrono::seconds{ 1 });
BOOST_ASIO_CORO_YIELD
wr_timer.async_wait(std::move(self));
if(ec)
return self.complete(ec, n);
wr_remain_ = wr_limit_;
}

BOOST_ASIO_CORO_YIELD
stream_->async_write_some(
buffers::prefix(buffers, wr_remain_),
std::move(self));

wr_remain_ -= n;
self.complete(ec, n);
}
Expand All @@ -175,19 +177,21 @@ class any_stream
{
BOOST_ASIO_CORO_REENTER(c)
{
self.reset_cancellation_state(
asio::enable_total_cancellation{});
if(rd_remain_ == 0)
{
rd_timer.expires_after(std::chrono::seconds{ 1 });
BOOST_ASIO_CORO_YIELD
rd_timer.async_wait(std::move(self));
if(ec)
return self.complete(ec, n);
rd_remain_ = rd_limit_;
}

BOOST_ASIO_CORO_YIELD
stream_->async_read_some(
buffers::prefix(buffers, rd_remain_),
std::move(self));

rd_remain_ -= n;
self.complete(ec, n);
}
Expand Down
2 changes: 1 addition & 1 deletion example/client/burl/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ parse_args(int argc, char* argv[])
is_file = true;

if(!filename && prefix != '<')
filename = fs::path{ value }.filename();
filename = fs::path{ value }.filename().string();

if(value == "-")
{
Expand Down
3 changes: 3 additions & 0 deletions example/client/burl/request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class async_request_op

BOOST_ASIO_CORO_REENTER(c)
{
self.reset_cancellation_state(
asio::enable_total_cancellation{});

BOOST_ASIO_CORO_YIELD
http_io::async_write(stream_, serializer_, std::move(self));

Expand Down

0 comments on commit b028cd0

Please sign in to comment.