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:
Damian Jarek
2019-04-05 05:08:31 -07:00
committed by Vinnie Falco
parent 50d5b965dd
commit ce986118f8
3 changed files with 16 additions and 6 deletions
+8 -4
View File
@@ -503,13 +503,17 @@ public:
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<
test::handler,
decltype(h),
net::io_context::executor_type> op(
test::any_handler(), ioc.get_executor());
std::move(h),
ioc1.get_executor());
op.complete(false);
ioc.run();
BEAST_EXPECT(ioc1.run() == 0);
BEAST_EXPECT(ioc2.run() == 1);
}
{
stable_async_base<