module: Fix unsafe iteration

This fixes an issue when requesting module unload for
module-bluetooth-discover. When unloading the module, it also unloads
module-bluez4-discover and/or module-bluez5-discover, and that
invalidated the state variable that was used for iterating through the
modules idxset.

The pa_module.unload_requested flag could now otherwise be removed,
but it's still being (ab)used in the bluetooth modules.
This commit is contained in:
Tanu Kaskinen 2014-12-05 15:51:35 +02:00
parent 686baf80d9
commit 2b6632e851
3 changed files with 11 additions and 5 deletions

View file

@ -117,7 +117,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, bool shared, size_t shm_size) {
c->deferred_volume_extra_delay_usec = 0;
c->module_defer_unload_event = NULL;
c->scache_auto_unload_event = NULL;
c->modules_pending_unload = pa_hashmap_new(NULL, NULL);
c->subscription_defer_event = NULL;
PA_LLIST_HEAD_INIT(pa_subscription, c->subscriptions);
@ -133,6 +133,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, bool shared, size_t shm_size) {
pa_mempool_set_is_remote_writable(c->rw_mempool, true);
c->exit_event = NULL;
c->scache_auto_unload_event = NULL;
c->exit_idle_time = -1;
c->scache_idle_time = 20;
@ -204,6 +205,9 @@ static void core_free(pa_object *o) {
pa_assert(pa_hashmap_isempty(c->shared));
pa_hashmap_free(c->shared);
pa_assert(pa_hashmap_isempty(c->modules_pending_unload));
pa_hashmap_free(c->modules_pending_unload);
pa_subscription_free_all(c);
if (c->exit_event)