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

Ensure that plugin_shutdown() is always called. #26

Merged
merged 1 commit into from
May 25, 2023
Merged

Conversation

greg7mdp
Copy link
Contributor

@greg7mdp greg7mdp commented May 25, 2023

Even if there was an exception during plugin_startup().

Resolves AntelopeIO/leap#25.

Currently, because a plugin is stored in the running_plugins list only after plugin_startup(), it would not be present if it throws during plugin_startup(), and as a consequence plugin_shutdown() would not be called on this plugin.

We need to make sure that plugin_shutdown() is called regardless of whether plugin_startup() completed successfully or not. That way, plugins can rest assured that whatever thread_pool or timer they started during plugin_startup() will be cleaned up, and no lambda referencing the plugin will be executed after the plugin is destroyed by the framework.

The fix is just flipping two lines in abstract_plugin::startup(). The rest is just adding a test to verify that the fix indeed works.

see parent issue AntelopeIO/spring#842.

@greg7mdp greg7mdp requested a review from heifner May 25, 2023 14:14
@greg7mdp greg7mdp requested a review from vladtr May 25, 2023 16:01
@greg7mdp greg7mdp merged commit 65bb056 into main May 25, 2023
@greg7mdp greg7mdp deleted the appbase_gh_25 branch May 25, 2023 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants