From b8a34a1dc0285259408365695119dd29747fcd34 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Sat, 15 Jul 2017 16:27:46 +1000 Subject: [PATCH] Fix work counting issue in asynchronous resolver implementation. --- asio/include/asio/detail/resolve_query_op.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/asio/include/asio/detail/resolve_query_op.hpp b/asio/include/asio/detail/resolve_query_op.hpp index cc45a447e9..d68cb7e9f2 100644 --- a/asio/include/asio/detail/resolve_query_op.hpp +++ b/asio/include/asio/detail/resolve_query_op.hpp @@ -67,7 +67,6 @@ class resolve_query_op : public resolve_op // Take ownership of the operation object. resolve_query_op* o(static_cast(base)); ptr p = { asio::detail::addressof(o->handler_), o, o }; - handler_work w(o->handler_); if (owner && owner != &o->io_context_impl_) { @@ -88,6 +87,9 @@ class resolve_query_op : public resolve_op // The operation has been returned to the main io_context. The completion // handler is ready to be delivered. + // Take ownership of the operation's outstanding work. + handler_work w(o->handler_); + ASIO_HANDLER_COMPLETION((*o)); // Make a copy of the handler so that the memory can be deallocated