pulse-server: handle if the module is destroyed while loading

Create a new event for modules ('destroy') which is emitted from
`module_free()`. It is used by the module loading logic, to handle
when a module is destroyed without properly loading first.
This commit is contained in:
Barnabás Pőcze 2021-11-12 18:54:17 +01:00 committed by Wim Taymans
parent bd5a715200
commit 0e75b3fa0f
3 changed files with 10 additions and 0 deletions

View file

@ -4666,6 +4666,11 @@ static void on_module_loaded(void *data, int result)
free(pm);
}
static void on_module_destroy(void *data)
{
on_module_loaded(data, -ECANCELED);
}
static void on_client_disconnect(void *data)
{
struct pending_module *pm = data;
@ -4679,6 +4684,7 @@ static int do_load_module(struct client *client, uint32_t command, uint32_t tag,
static const struct module_events module_events = {
VERSION_MODULE_EVENTS,
.loaded = on_module_loaded,
.destroy = on_module_destroy,
};
static const struct client_events client_events = {
VERSION_CLIENT_EVENTS,