From ae1f75109cd5c5c96c73e3250e9ab67f3e1b66d3 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 6 Dec 2022 08:24:02 -0600 Subject: [PATCH] Handle shutdown of http_plugin lifetime --- plugins/http_plugin/http_plugin.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/http_plugin/http_plugin.cpp b/plugins/http_plugin/http_plugin.cpp index b445d4effa..45348f2008 100644 --- a/plugins/http_plugin/http_plugin.cpp +++ b/plugins/http_plugin/http_plugin.cpp @@ -101,6 +101,7 @@ class http_plugin_impl : public std::enable_shared_from_this { // sole ownership of the tracked body and the passed in parameters app().post( priority, [next_ptr, conn=std::move(conn), r=std::move(r), tracked_b, wrapped_then=std::move(wrapped_then)]() mutable { try { + if( app().is_quiting() ) return; // http_plugin shutting down, do not call callback // call the `next` url_handler and wrap the response handler (*next_ptr)( std::move( r ), std::move(tracked_b->obj()), std::move(wrapped_then)) ; } catch( ... ) { @@ -474,8 +475,6 @@ class http_plugin_impl : public std::enable_shared_from_this { // release http_plugin_impl_ptr shared_ptrs captured in url handlers my->plugin_state->url_handlers.clear(); - - app().post( 0, [me = my](){} ); // keep my pointer alive until queue is drained } void http_plugin::add_handler(const string& url, const url_handler& handler, int priority) {