Return -EEXIST when registering an object twice

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

View file

@ -215,6 +215,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

@ -142,6 +142,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

@ -1280,6 +1280,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

@ -426,6 +426,9 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
struct pw_type *t = &core->type; struct pw_type *t = &core->type;
const char *str, *dir; const char *str, *dir;
if (port->node != NULL)
return -EEXIST;
port->node = node; port->node = node;
spa_node_port_get_info(node->node, spa_node_port_get_info(node->node,
@ -537,6 +540,7 @@ static void pw_port_remove(struct pw_port *port)
} }
spa_list_remove(&port->link); spa_list_remove(&port->link);
pw_node_events_port_removed(node, port); pw_node_events_port_removed(node, port);
port->node = NULL;
} }
void pw_port_destroy(struct pw_port *port) void pw_port_destroy(struct pw_port *port)