From c95e69368d704dd5ab4529f4cb3851080afa5ccc Mon Sep 17 00:00:00 2001 From: Christian Eggers Date: Thu, 4 Jul 2024 13:28:05 +0200 Subject: [PATCH] example: operations/composed_6: also free delay_timer_ Also the delay_timer_ member should be freed before calling the user-supplied completion handler (as in the composed_7 and composed_8 examples). Signed-off-by: Christian Eggers --- asio/src/examples/cpp11/operations/composed_6.cpp | 5 +++-- asio/src/examples/cpp14/operations/composed_6.cpp | 5 +++-- asio/src/examples/cpp20/operations/composed_6.cpp | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/asio/src/examples/cpp11/operations/composed_6.cpp b/asio/src/examples/cpp11/operations/composed_6.cpp index b948758d83..70b64502fb 100644 --- a/asio/src/examples/cpp11/operations/composed_6.cpp +++ b/asio/src/examples/cpp11/operations/composed_6.cpp @@ -138,9 +138,10 @@ struct async_write_message_initiation // We no longer have any future work coming for the I/O executor. io_work_.reset(); - // Deallocate the encoded message before calling the user-supplied - // completion handler. + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. encoded_message_.reset(); + delay_timer_.reset(); // Call the user-supplied handler with the result of the operation. handler_(error); diff --git a/asio/src/examples/cpp14/operations/composed_6.cpp b/asio/src/examples/cpp14/operations/composed_6.cpp index 82c0cd7223..b056272b76 100644 --- a/asio/src/examples/cpp14/operations/composed_6.cpp +++ b/asio/src/examples/cpp14/operations/composed_6.cpp @@ -156,9 +156,10 @@ auto async_write_messages(tcp::socket& socket, // We no longer have any future work coming for the I/O executor. io_work_.reset(); - // Deallocate the encoded message before calling the user-supplied - // completion handler. + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. encoded_message_.reset(); + delay_timer_.reset(); // Call the user-supplied handler with the result of the operation. handler_(error); diff --git a/asio/src/examples/cpp20/operations/composed_6.cpp b/asio/src/examples/cpp20/operations/composed_6.cpp index 77e2f50f93..da89886d55 100644 --- a/asio/src/examples/cpp20/operations/composed_6.cpp +++ b/asio/src/examples/cpp20/operations/composed_6.cpp @@ -161,9 +161,10 @@ auto async_write_messages(tcp::socket& socket, // We no longer have any future work coming for the I/O executor. io_work_.reset(); - // Deallocate the encoded message before calling the user-supplied - // completion handler. + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. encoded_message_.reset(); + delay_timer_.reset(); // Call the user-supplied handler with the result of the operation. handler_(error);