Skip to content

Commit d116440

Browse files
committedAug 14, 2023
limited immediate to initiate state.
1 parent f1fe41f commit d116440

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
 

‎include/boost/async/detail/handler.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,18 @@ struct completion_handler_noop_executor : executor
3232
template<typename Fn>
3333
void execute(Fn && fn) const
3434
{
35+
// only allow it when we're still initializing
3536
if (completed_immediately &&
36-
//avoid recursion. i.e. don't let multiple sup operations complete immediately.
37-
*completed_immediately != completed_immediately_t::maybe)
37+
((*completed_immediately == completed_immediately_t::initiating)
38+
|| (*completed_immediately == completed_immediately_t::maybe)))
3839
{
3940
// only use this indicator if the fn will actually call our completion-handler
4041
// otherwise this was a single op in a composed operation
4142
*completed_immediately = completed_immediately_t::maybe;
4243
fn();
4344
// yes means completion_handler::operator() was called, so we're good.
4445
if (*completed_immediately != completed_immediately_t::yes)
45-
*completed_immediately = completed_immediately_t::no;
46+
*completed_immediately = completed_immediately_t::initiating;
4647
}
4748
else
4849
{

‎test/handler.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct immediate_aw
4444
&completed_immediately};
4545

4646
auto exec = asio::get_associated_immediate_executor(ch, h.promise().get_executor());
47+
completed_immediately = async::detail::completed_immediately_t::initiating;
4748
asio::dispatch(exec, std::move(ch));
4849

4950
CHECK(result);

0 commit comments

Comments
 (0)