pipewire: module-zeroconf-discover: handle module destroy events
module-zeroconf-discover
loads module-pulse-tunnel for each entity exposed on the network. Previously, however, the destroy event of the loaded pulse-tunnel
modules were not handled.
This resulted in a use-after-free because both pw_context_destroy()
and module-zeroconf-discover.c:impl_free()
tried to destroy the pulse-tunnel modules. The reason for that is that since 1de16afc the modules
are prepended to the module list of the context, not appended, therefore modules are destroyed in LIFO order, thus the pulse-tunnel
modules were destroyed before the zeroconf-discover
module that loaded them.
Fix that by handling the destroy event of the loaded pulse-tunnel modules.
Fixes #1653 (closed)
This change relies on the fact that pw_impl_module_add_listener()
immediately, synchronously emits the destroy event.
@wtaymans Out of curiosity, can you shed some light on why the module order was changed in 1de16afc? And I noticed there was already a module_listener
in struct tunnel
, but I haven't found anything relevant in git; was the event handling present in an earlier revision?