Return -EEXIST when registering an object twice

This commit is contained in:
Wim Taymans 2019-05-22 10:09:12 +02:00
parent fbf6acd271
commit f57a806cf8
4 changed files with 10 additions and 0 deletions

View file

@ -311,6 +311,9 @@ int pw_client_register(struct pw_client *client,
{ {
struct pw_core *core = client->core; struct pw_core *core = client->core;
if (client->registered)
return -EEXIST;
pw_log_debug("client %p: register parent %d", client, parent ? parent->id : SPA_ID_INVALID); pw_log_debug("client %p: register parent %d", client, parent ? parent->id : SPA_ID_INVALID);
spa_list_append(&core->client_list, &client->link); spa_list_append(&core->client_list, &client->link);

View file

@ -146,6 +146,9 @@ int pw_factory_register(struct pw_factory *factory,
{ {
struct pw_core *core = factory->core; struct pw_core *core = factory->core;
if (factory->registered)
return -EEXIST;
if (properties == NULL) if (properties == NULL)
properties = pw_properties_new(NULL, NULL); properties = pw_properties_new(NULL, NULL);
if (properties == NULL) if (properties == NULL)

View file

@ -1394,6 +1394,9 @@ int pw_link_register(struct pw_link *link,
struct pw_core *core = link->core; struct pw_core *core = link->core;
struct pw_node *input_node, *output_node; struct pw_node *input_node, *output_node;
if (link->registered)
return -EEXIST;
if (properties == NULL) if (properties == NULL)
properties = pw_properties_new(NULL, NULL); properties = pw_properties_new(NULL, NULL);
if (properties == NULL) if (properties == NULL)

View file

@ -785,6 +785,7 @@ static void pw_port_remove(struct pw_port *port)
} }
spa_list_remove(&port->link); spa_list_remove(&port->link);
pw_node_emit_port_removed(node, port); pw_node_emit_port_removed(node, port);
port->node = NULL;
} }
void pw_port_destroy(struct pw_port *port) void pw_port_destroy(struct pw_port *port)