core: destroy all resources on hello

Destroy all resources (except the core) for a client when it
does a hello. This typically needs to be done after passing the
connection fd from one client to another.
This commit is contained in:
Wim Taymans 2019-05-06 17:05:05 +02:00
parent 2b5c6fd676
commit 7670ee7eec

View file

@ -102,13 +102,23 @@ static const struct pw_resource_events resource_events = {
.destroy = destroy_registry_resource
};
static int destroy_resource(void *object, void *data)
{
struct pw_resource *resource = object;
if (resource && resource != resource->client->core_resource)
pw_resource_destroy(resource);
return 0;
}
static void core_hello(void *object)
{
struct pw_resource *resource = object;
struct pw_client *client = resource->client;
struct pw_core *this = resource->core;
pw_log_debug("core %p: hello from source %p", this, resource);
resource->client->n_types = 0;
pw_log_debug("core %p: hello from resource %p", this, resource);
client->n_types = 0;
pw_map_for_each(&client->objects, destroy_resource, client);
this->info.change_mask = PW_CORE_CHANGE_MASK_ALL;
pw_core_resource_info(resource, &this->info);