mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-14 06:59:57 -05:00
module: handle global destroy properly
When the global is destroyed, we remove our listeners and set the global to NULL. We then destroy the module but because the global is NULL, we don't remove ourselves from the list of modules, causing a crash later. Fix this by always adding ourself to the list of modules and always removing ourselves on destroy. See #565
This commit is contained in:
parent
73694f72ee
commit
15431570f4
1 changed files with 4 additions and 3 deletions
|
|
@ -239,6 +239,8 @@ pw_context_load_module(struct pw_context *context,
|
|||
filename = NULL;
|
||||
this->info.args = args ? strdup(args) : NULL;
|
||||
|
||||
spa_list_prepend(&context->module_list, &this->link);
|
||||
|
||||
this->global = pw_global_new(context,
|
||||
PW_TYPE_INTERFACE_Module,
|
||||
PW_VERSION_MODULE,
|
||||
|
|
@ -249,8 +251,6 @@ pw_context_load_module(struct pw_context *context,
|
|||
if (this->global == NULL)
|
||||
goto error_no_global;
|
||||
|
||||
spa_list_prepend(&context->module_list, &this->link);
|
||||
|
||||
this->info.id = this->global->id;
|
||||
pw_properties_setf(this->properties, PW_KEY_OBJECT_ID, "%d", this->info.id);
|
||||
pw_properties_setf(this->properties, PW_KEY_OBJECT_SERIAL, "%"PRIu64,
|
||||
|
|
@ -323,8 +323,9 @@ void pw_impl_module_destroy(struct pw_impl_module *module)
|
|||
pw_log_debug("%p: destroy", module);
|
||||
pw_impl_module_emit_destroy(module);
|
||||
|
||||
spa_list_remove(&module->link);
|
||||
|
||||
if (module->global) {
|
||||
spa_list_remove(&module->link);
|
||||
spa_hook_remove(&module->global_listener);
|
||||
pw_global_destroy(module->global);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue