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

@ -142,7 +142,7 @@ static void run_mix_test(
pa_memblock_unref(c0.memblock);
pa_memblock_unref(c1.memblock);
pa_mempool_free(pool);
pa_mempool_unref(pool);
}
START_TEST (mix_special_test) {

View file

@ -163,7 +163,7 @@ START_TEST (lfe_filter_test) {
pa_lfe_filter_free(lft.lf);
pa_mempool_free(lft.pool);
pa_mempool_unref(lft.pool);
if (!ret)
pa_log_debug("lfe-filter-test: tests for both rewind to block boundary and rewind to middle position of a block passed!");

View file

@ -100,7 +100,7 @@ int main(int argc, char *argv[]) {
if (c.memblock)
pa_memblock_unref(c.memblock);
pa_mempool_free(p);
pa_mempool_unref(p);
return 0;
}

View file

@ -169,9 +169,9 @@ START_TEST (memblock_test) {
pa_log("vacuuming done...");
pa_mempool_free(pool_a);
pa_mempool_free(pool_b);
pa_mempool_free(pool_c);
pa_mempool_unref(pool_a);
pa_mempool_unref(pool_b);
pa_mempool_unref(pool_c);
}
END_TEST

View file

@ -208,7 +208,7 @@ START_TEST (memblockq_test) {
pa_memblock_unref(chunk3.memblock);
pa_memblock_unref(chunk4.memblock);
pa_mempool_free(p);
pa_mempool_unref(p);
}
END_TEST

View file

@ -338,7 +338,7 @@ START_TEST (mix_test) {
pa_memblock_unref(k.memblock);
}
pa_mempool_free(pool);
pa_mempool_unref(pool);
}
END_TEST

View file

@ -75,7 +75,7 @@ int main(int argc, char *argv[]) {
pa_resampler_free(r);
}
pa_mempool_free(pool);
pa_mempool_unref(pool);
return 0;
}

View file

@ -473,7 +473,7 @@ int main(int argc, char *argv[]) {
quit:
if (pool)
pa_mempool_free(pool);
pa_mempool_unref(pool);
return ret;
}

View file

@ -116,7 +116,7 @@ START_TEST (srbchannel_test) {
pa_pstream_unref(p1);
pa_pstream_unref(p2);
pa_mempool_free(mp);
pa_mempool_unref(mp);
pa_mainloop_free(ml);
}
END_TEST