Skip to content

Conversation

@MungoG
Copy link
Collaborator

@MungoG MungoG commented Nov 25, 2025

No description provided.

@cppalliance-bot
Copy link

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 84.46602% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.96%. Comparing base (4efe8e8) to head (303cb20).

Files with missing lines Patch % Lines
include/boost/beast2/test/impl/stream.hpp 89.88% 9 Missing ⚠️
include/boost/beast2/test/detail/stream_state.hpp 50.00% 4 Missing ⚠️
include/boost/beast2/impl/write.hpp 50.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #102      +/-   ##
===========================================
+ Coverage    53.19%   56.96%   +3.77%     
===========================================
  Files           38       38              
  Lines         1690     1808     +118     
===========================================
+ Hits           899     1030     +131     
+ Misses         791      778      -13     
Files with missing lines Coverage Δ
include/boost/beast2/test/stream.hpp 100.00% <ø> (ø)
include/boost/beast2/impl/write.hpp 45.09% <50.00%> (+45.09%) ⬆️
include/boost/beast2/test/detail/stream_state.hpp 83.33% <50.00%> (-1.29%) ⬇️
include/boost/beast2/test/impl/stream.hpp 93.95% <89.88%> (+2.46%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4efe8e8...303cb20. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 84.46602% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.96%. Comparing base (4efe8e8) to head (303cb20).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
include/boost/beast2/test/impl/stream.hpp 89.88% 9 Missing ⚠️
include/boost/beast2/test/detail/stream_state.hpp 50.00% 4 Missing ⚠️
include/boost/beast2/impl/write.hpp 50.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #102      +/-   ##
===========================================
+ Coverage    53.19%   56.96%   +3.77%     
===========================================
  Files           38       38              
  Lines         1690     1808     +118     
===========================================
+ Hits           899     1030     +131     
+ Misses         791      778      -13     
Files with missing lines Coverage Δ
include/boost/beast2/test/stream.hpp 100.00% <ø> (ø)
include/boost/beast2/impl/write.hpp 45.09% <50.00%> (+45.09%) ⬆️
include/boost/beast2/test/detail/stream_state.hpp 83.33% <50.00%> (-1.29%) ⬇️
include/boost/beast2/test/impl/stream.hpp 93.95% <89.88%> (+2.46%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4efe8e8...303cb20. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}
n_ += bytes_transferred;

if(!!self.cancelled() && ! sr_.is_done())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this condition should go before BOOST_ASIO_CORO_YIELD (the first thing that happens inside the loop). That way you don't need to check sr_.is_done(). Also, the current code swallows network errors if a cancellation happens afterwards, which is incorrect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point about the network errors, thank you.
If we emit a cancellation immediately after async_write what is the correct behaviour? Currently it will write some bytes and then the handler is called with non-zero n and an operation_aborted value of ec. Moving this to the top of the loop means that scenario will not write anything and n will be zero.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If asycn_write_asome completes before cancellation it would be caught in the next attempt to write, if asycn_write_asome completes with operation_aborted then the loop exits because of if(ec.failed) branch.

}
sr_.consume(bytes_transferred);

if(!!self.cancelled() && !sr_.is_done())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition seems unnecessary, since we are not looping for another write, it doesn't matter whether async_write_some completes after the cancellation or before it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it because, without this check, the following test does not produce the expected value of ec:
https://github.com/cppalliance/beast2/pull/102/files#diff-13a376592ec7d2e701ab2d597d68a2344c77761e8020e060f4eafdc2a1b39ea1R166-R200

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link doesn’t work (it doesn’t point to a line number), but I guess the issue is related to the fact that async_write_some on test::stream completes immediately and there’s currently no way to prevent that. If that’s the case, we need a mechanism in test::stream to limit the read buffer so that even the first async_write_some doesn’t complete immediately.


//------------------------------------------------------------------------------

struct stream_write_op_base
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this change to op_base and used for both read and write ops?

Comment on lines 146 to 154
std::vector<std::unique_ptr<detail::stream_read_op_base>> v;
std::lock_guard<std::mutex> g1(sp_->m_);
v.reserve(sp_->v_.size());
for(auto p : sp_->v_)
{
std::lock_guard<std::mutex> g2(p->m);
v.emplace_back(std::move(p->op));
v.emplace_back(std::move(p->rop));
p->code = detail::stream_status::eof;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stream_service::shutdown() should also destroy hanging write operations on shutdown.

@vinniefalco
Copy link
Member

please flatten this branch (no merge commits)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants