core: handle client bind errors

When a client attempts to bind to an unexisting global, don't error
but instead let the client know the object was removed.
This commit is contained in:
Wim Taymans 2017-03-09 15:52:19 +01:00
parent 7ad02f553a
commit 1e600713a5
6 changed files with 14 additions and 4 deletions

View file

@ -64,6 +64,7 @@ client_bind_func (PinosGlobal *global,
return SPA_RESULT_OK;
no_mem:
pinos_log_error ("can't create client resource");
pinos_core_notify_error (client->core_resource,
client->core_resource->id,
SPA_RESULT_NO_MEMORY,

View file

@ -60,10 +60,13 @@ registry_bind (void *object,
return;
no_id:
pinos_core_notify_error (client->core_resource,
resource->id,
SPA_RESULT_INVALID_OBJECT_ID,
"unknown object id %u", id);
pinos_log_debug ("registry %p: no global with id %u to bind to %u", resource, id, new_id);
/* unmark the new_id the map, the client does not yet know about the failed
* bind and will choose the next id, which we would refuse when we don't mark
* new_id as 'used and freed' */
pinos_map_insert_at (&client->objects, new_id, NULL);
pinos_core_notify_remove_id (client->core_resource, new_id);
return;
}
static PinosRegistryMethods registry_methods = {
@ -128,6 +131,7 @@ core_get_registry (void *object,
return;
no_mem:
pinos_log_error ("can't create registry resource");
pinos_core_notify_error (client->core_resource,
resource->id,
SPA_RESULT_NO_MEMORY,
@ -195,6 +199,7 @@ core_create_client_node (void *object,
return;
no_mem:
pinos_log_error ("can't create client node");
pinos_core_notify_error (client->core_resource,
resource->id,
SPA_RESULT_NO_MEMORY,

View file

@ -760,6 +760,7 @@ link_bind_func (PinosGlobal *global,
return SPA_RESULT_OK;
no_mem:
pinos_log_error ("can't create link resource");
pinos_core_notify_error (client->core_resource,
client->core_resource->id,
SPA_RESULT_NO_MEMORY,

View file

@ -115,6 +115,7 @@ module_bind_func (PinosGlobal *global,
return SPA_RESULT_OK;
no_mem:
pinos_log_error ("can't create module resource");
pinos_core_notify_error (client->core_resource,
client->core_resource->id,
SPA_RESULT_NO_MEMORY,

View file

@ -443,6 +443,7 @@ node_bind_func (PinosGlobal *global,
return SPA_RESULT_OK;
no_mem:
pinos_log_error ("can't create node resource");
pinos_core_notify_error (client->core_resource,
client->core_resource->id,
SPA_RESULT_NO_MEMORY,

View file

@ -51,6 +51,7 @@ pinos_resource_new (PinosClient *client,
pinos_signal_init (&this->destroy_signal);
if (!pinos_map_insert_at (&client->objects, this->id, this)) {
pinos_log_debug ("resource %p: id %u in use for client %p", this, id, client);
free (impl);
return NULL;
}