pulsecore: Reference count mempools

In future commits, server-wide SHMs will be replaced with per-client
ones that will be dynamically created and freed according to clients
connections open and close.

Meanwhile, current PA design does not guarantee that the per-client
mempool blocks are referenced only by client-specific objects.

Thus reference count the pools and let each memblock inside the pool
itself, or just attached to it, increment the pool's refcount upon
allocation. This way, per-client mempools will only be freed when no
further component in the system holds any references to its blocks.

DiscussionLink: https://goo.gl/qesVMV
Suggested-by: Tanu Kaskinen <tanuk@iki.fi>
Suggested-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
This commit is contained in:
Ahmed S. Darwish 2016-03-13 00:51:12 +02:00 committed by David Henningsson
parent 1f5e72264e
commit 9bda6e344a
17 changed files with 84 additions and 20 deletions

View file

@ -218,8 +218,8 @@ static void core_free(pa_object *o) {
pa_silence_cache_done(&c->silence_cache);
if (c->rw_mempool)
pa_mempool_free(c->rw_mempool);
pa_mempool_free(c->mempool);
pa_mempool_unref(c->rw_mempool);
pa_mempool_unref(c->mempool);
for (j = 0; j < PA_CORE_HOOK_MAX; j++)
pa_hook_done(&c->hooks[j]);