mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 21:07:26 +02:00
Fix async_base immediate completion
`complete(false, ...)` used the wrong executor when an async operation completed immediately, potentially executing the completion handler on the IO executor in some cases. Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
committed by
Vinnie Falco
parent
50d5b965dd
commit
ce986118f8
@ -1,3 +1,9 @@
|
|||||||
|
Version 247:
|
||||||
|
|
||||||
|
* Fix async_base immediate completion
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Version 246:
|
Version 246:
|
||||||
|
|
||||||
* decorator ctor is explicit
|
* decorator ctor is explicit
|
||||||
|
@ -340,7 +340,7 @@ public:
|
|||||||
if(! is_continuation)
|
if(! is_continuation)
|
||||||
{
|
{
|
||||||
net::post(net::bind_executor(
|
net::post(net::bind_executor(
|
||||||
wg1_.get_executor(),
|
get_executor(),
|
||||||
beast::bind_front_handler(
|
beast::bind_front_handler(
|
||||||
std::move(h_),
|
std::move(h_),
|
||||||
std::forward<Args>(args)...)));
|
std::forward<Args>(args)...)));
|
||||||
@ -348,8 +348,8 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
h_(std::forward<Args>(args)...);
|
|
||||||
wg1_.reset();
|
wg1_.reset();
|
||||||
|
h_(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,13 +503,17 @@ public:
|
|||||||
op.complete(true);
|
op.complete(true);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
net::io_context ioc;
|
net::io_context ioc1;
|
||||||
|
net::io_context ioc2;
|
||||||
|
auto h = net::bind_executor(ioc2, test::any_handler());
|
||||||
stable_async_base<
|
stable_async_base<
|
||||||
test::handler,
|
decltype(h),
|
||||||
net::io_context::executor_type> op(
|
net::io_context::executor_type> op(
|
||||||
test::any_handler(), ioc.get_executor());
|
std::move(h),
|
||||||
|
ioc1.get_executor());
|
||||||
op.complete(false);
|
op.complete(false);
|
||||||
ioc.run();
|
BEAST_EXPECT(ioc1.run() == 0);
|
||||||
|
BEAST_EXPECT(ioc2.run() == 1);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
stable_async_base<
|
stable_async_base<
|
||||||
|
Reference in New Issue
Block a user