pulse-server: module: do not schedule unloading multiple times

While it is not a problem since `module_free()` calls
`pw_work_queue_cancel()`, it is completely unnecessary
to do it more than once.

Introduce a new flag on the module which stores whether or
not an unloading has been scheduled.
This commit is contained in:
Barnabás Pőcze 2021-12-28 19:21:01 +01:00 committed by Wim Taymans
parent 4fbe3cbfc6
commit b08da23715
2 changed files with 6 additions and 2 deletions

View file

@ -50,8 +50,11 @@ static void on_module_unload(void *obj, void *data, int res, uint32_t id)
void module_schedule_unload(struct module *module)
{
struct impl *impl = module->impl;
pw_work_queue_add(impl->work_queue, module, 0, on_module_unload, impl);
if (module->unloading)
return;
pw_work_queue_add(module->impl->work_queue, module, 0, on_module_unload, NULL);
module->unloading = true;
}
struct module *module_new(struct impl *impl, const struct module_methods *methods, size_t user_data)