As various modules can subscribe to unlink callbacks unloading some modules
may trigger hooks in other modules.
The callbacks associated with these hooks could in turn need to use the core
in some capacity (e.g. perhaps they are module loading modules
(e.g. *-discover, filter-apply or gconf etc. and need to use the core to
unload modules they've loaded).
This change simply ensures that all modules and cached samples are unloaded
before freeing the core.
#endif
if (c) {
+ /* Ensure all the modules/samples are unloaded when the core is still ref'ed,
+ * as unlink callback hooks in modules may need the core to be ref'ed */
+ pa_module_unload_all(c);
+ pa_scache_free_all(c);
+
pa_core_unref(c);
pa_log_info(_("Daemon terminated."));
}
c->state = PA_CORE_SHUTDOWN;
- pa_module_unload_all(c);
- pa_scache_free_all(c);
+ /* Note: All modules and samples in the cache should be unloaded before
+ * we get here */
pa_assert(pa_idxset_isempty(c->scache));
pa_idxset_free(c->scache, NULL, NULL);