mirror of git://git.sysmocom.de/ofono
plugin: Don't unload external plugins too early
Plugins may reference data structures allocated by each other. They all need to be deinitialized first, only then it should be safe to unload the libraries.
This commit is contained in:
parent
3c10ae7fb3
commit
376af6c85c
15
src/plugin.c
15
src/plugin.c
|
@ -190,17 +190,26 @@ void __ofono_plugin_cleanup(void)
|
|||
|
||||
DBG("");
|
||||
|
||||
/*
|
||||
* Terminate the plugins but don't unload the libraries yet.
|
||||
* Plugins may reference data structures allocated by each other.
|
||||
*/
|
||||
for (list = plugins; list; list = list->next) {
|
||||
struct ofono_plugin *plugin = list->data;
|
||||
|
||||
if (plugin->active == TRUE && plugin->desc->exit)
|
||||
plugin->desc->exit();
|
||||
}
|
||||
|
||||
/* Second pass - unload the libraries */
|
||||
for (list = plugins; list; list = list->next) {
|
||||
struct ofono_plugin *plugin = list->data;
|
||||
|
||||
if (plugin->handle)
|
||||
dlclose(plugin->handle);
|
||||
|
||||
g_free(plugin);
|
||||
}
|
||||
|
||||
g_slist_free(plugins);
|
||||
/* Finally, free the memory */
|
||||
g_slist_free_full(plugins, g_free);
|
||||
plugins = NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue