pulse-server: don't broadcast remove event when a module wasn't loaded

This commit is contained in:
Barnabás Pőcze 2021-06-06 15:49:58 +02:00
parent f26358e958
commit 4d02233ff3
3 changed files with 9 additions and 5 deletions

View file

@ -53,6 +53,7 @@ struct module *module_new(struct impl *impl, const struct module_methods *method
module->methods = methods;
spa_hook_list_init(&module->listener_list);
module->user_data = SPA_PTROFF(module, sizeof(struct module), void);
module->loaded = false;
return module;
}
@ -94,7 +95,6 @@ static void module_free(struct module *module)
static int module_unload(struct client *client, struct module *module)
{
struct impl *impl = module->impl;
uint32_t module_idx = module->idx;
int res = 0;
/* Note that client can be NULL (when the module is being unloaded
@ -105,12 +105,13 @@ static int module_unload(struct client *client, struct module *module)
if (module->methods->unload)
res = module->methods->unload(client, module);
module_free(module);
broadcast_subscribe_event(impl,
if (module->loaded)
broadcast_subscribe_event(impl,
SUBSCRIPTION_MASK_MODULE,
SUBSCRIPTION_EVENT_REMOVE | SUBSCRIPTION_EVENT_MODULE,
module_idx);
module->idx);
module_free(module);
return res;
}