core: don't send remove_id in hello

The hello method should also destroy the resources for a client but not
send a remove_id for them.
This commit is contained in:
Wim Taymans 2019-05-10 12:09:26 +02:00
parent 5d2f0f5182
commit e0eeedc369
5 changed files with 14 additions and 5 deletions

View file

@ -105,8 +105,10 @@ static const struct pw_resource_events resource_events = {
static int destroy_resource(void *object, void *data)
{
struct pw_resource *resource = object;
if (resource && resource != resource->client->core_resource)
if (resource && resource != resource->client->core_resource) {
resource->removed = true;
pw_resource_destroy(resource);
}
return 0;
}

View file

@ -117,6 +117,9 @@ struct pw_core_proxy_methods {
/**
* Start a conversation with the server. This will send
* the core info and server types.
*
* All the existing resources for the client (except the core
* resource) will be destroyed.
*/
void (*hello) (void *object);
/**

View file

@ -435,6 +435,8 @@ struct pw_resource {
uint32_t type; /**< type of the client interface */
uint32_t version; /**< version of the client interface */
bool removed; /**< if the resource was removed */
struct spa_hook implementation;
struct spa_hook_list implementation_list;
struct spa_hook_list listener_list;

View file

@ -181,10 +181,12 @@ static void core_event_remove_id(void *data, uint32_t id)
struct pw_proxy *proxy;
pw_log_debug("remote %p: object remove %u", this, id);
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL) {
if ((proxy = pw_map_lookup(&this->objects, id)) == NULL) {
pw_log_warn("remote %p: asked to remove unknown object id %u", this, id);
return;
}
pw_proxy_destroy(proxy);
pw_map_remove(&this->objects, id);
}
}
static void

View file

@ -176,7 +176,7 @@ void pw_resource_destroy(struct pw_resource *resource)
pw_map_insert_at(&client->objects, resource->id, NULL);
pw_client_events_resource_removed(client, resource);
if (client->core_resource)
if (client->core_resource && !resource->removed)
pw_core_resource_remove_id(client->core_resource, resource->id);
pw_log_debug("resource %p: free", resource);