summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2011-08-16 10:54:24 +0100
committerColin Guthrie <colin@mageia.org>2011-08-16 11:01:34 +0100
commit98ae74e052bfc6e44a4843e0d8a2e01d0e8e8107 (patch)
tree0b227b5ecbbaa28b4a3588f8b487d0b7122803ee
parent0d349462c776eee50a13e743bdc4a3ac220b086a (diff)
core: Unload the modules and cached samples before unref'ing the core.
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.
-rw-r--r--src/daemon/main.c5
-rw-r--r--src/pulsecore/core.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 55726fdb..1d0a65e3 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -1156,6 +1156,11 @@ finish:
#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."));
}
diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c
index 2a68fdf4..0e53b9d9 100644
--- a/src/pulsecore/core.c
+++ b/src/pulsecore/core.c
@@ -166,8 +166,8 @@ static void core_free(pa_object *o) {
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);