Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle shutdown of http_plugin lifetime #540

Merged
merged 1 commit into from
Dec 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions plugins/http_plugin/http_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class http_plugin_impl : public std::enable_shared_from_this<http_plugin_impl> {
// 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( ... ) {
Expand Down Expand Up @@ -474,8 +475,6 @@ class http_plugin_impl : public std::enable_shared_from_this<http_plugin_impl> {

// 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) {
Expand Down