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);
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;
}

View file

@ -63,6 +63,7 @@ struct module {
const struct module_methods *methods;
struct spa_hook_list listener_list;
void *user_data;
unsigned int loaded:1;
};
struct module *module_new(struct impl *impl, const struct module_methods *methods, size_t user_data);

View file

@ -5017,6 +5017,8 @@ static void on_module_loaded(void *data, int error)
pw_log_info(NAME" %p: [%s] module %d loaded", client->impl, client->name, module->idx);
module->loaded = true;
broadcast_subscribe_event(impl,
SUBSCRIPTION_MASK_MODULE,
SUBSCRIPTION_EVENT_NEW | SUBSCRIPTION_EVENT_MODULE,