-
Notifications
You must be signed in to change notification settings - Fork 6
Keep plugins in scope after loading #34
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
Conversation
| } | ||
| } | ||
|
|
||
| TEST(BoostPluginLoaderUnit, TestPluginLoaderScope) // NOLINT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Levi-Armstrong this unit test appears to work whether or not the internal cache introduced in this PR exists.
According to ldd the unit test only links to libboost_plugin_loader_example_plugin.so and libbboost_plugin_loader.so (not the library in which the triangle plugin was implemented - libboost_plugin_loader_example_plugin_impl.so), so the unit test itself shouldn't be loading the plugin library as part of its runtime requirement.
Any idea why this would work without holding onto the pointer to the plugin internally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the plugin_loader object which holds the pointer to the plugin (triangle factory)? So I think what you want is to place the creation of the plugin_loader object inside the brackets and have it go out of scope. Another option, if the method exist would be to remove the triangle factory from the plugin loader also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the plugin_loader object which holds the pointer to the plugin (triangle factory)?
Yes, this PR introduces this feature. However, the unit test still succeeds without the addition of this feature.
If this unit test is run after removing b587d66 it should fail because the library should be unloaded when the plugin (i.e., triangle_factory) goes out of scope. But it doesn't, and I'm wondering why it doesn't segfault at line 441
946dfb2 to
be5ad64
Compare
…he lifetime of the plugin loader
05eae2b to
544333e
Compare
|
Closing; addressed in #36 |
This PR adds an internal "cache" to the plugin loader to allow it to retain pointers to loaded plugins, thereby keeping the libraries that provide their functionality from being unloaded. This change helps prevent users from unintentionally unloading plugin libraries. As long as the plugin loader remains in scope, the loaded plugins should also stay in scope