mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	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:
		
							parent
							
								
									7ad02f553a
								
							
						
					
					
						commit
						1e600713a5
					
				
					 6 changed files with 14 additions and 4 deletions
				
			
		| 
						 | 
					@ -64,6 +64,7 @@ client_bind_func (PinosGlobal *global,
 | 
				
			||||||
  return SPA_RESULT_OK;
 | 
					  return SPA_RESULT_OK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
no_mem:
 | 
					no_mem:
 | 
				
			||||||
 | 
					  pinos_log_error ("can't create client resource");
 | 
				
			||||||
  pinos_core_notify_error (client->core_resource,
 | 
					  pinos_core_notify_error (client->core_resource,
 | 
				
			||||||
                           client->core_resource->id,
 | 
					                           client->core_resource->id,
 | 
				
			||||||
                           SPA_RESULT_NO_MEMORY,
 | 
					                           SPA_RESULT_NO_MEMORY,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,10 +60,13 @@ registry_bind (void     *object,
 | 
				
			||||||
  return;
 | 
					  return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
no_id:
 | 
					no_id:
 | 
				
			||||||
  pinos_core_notify_error (client->core_resource,
 | 
					  pinos_log_debug ("registry %p: no global with id %u to bind to %u", resource, id, new_id);
 | 
				
			||||||
                           resource->id,
 | 
					  /* unmark the new_id the map, the client does not yet know about the failed
 | 
				
			||||||
                           SPA_RESULT_INVALID_OBJECT_ID,
 | 
					   * bind and will choose the next id, which we would refuse when we don't mark
 | 
				
			||||||
                           "unknown object id %u", id);
 | 
					   * 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 = {
 | 
					static PinosRegistryMethods registry_methods = {
 | 
				
			||||||
| 
						 | 
					@ -128,6 +131,7 @@ core_get_registry (void     *object,
 | 
				
			||||||
  return;
 | 
					  return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
no_mem:
 | 
					no_mem:
 | 
				
			||||||
 | 
					  pinos_log_error ("can't create registry resource");
 | 
				
			||||||
  pinos_core_notify_error (client->core_resource,
 | 
					  pinos_core_notify_error (client->core_resource,
 | 
				
			||||||
                           resource->id,
 | 
					                           resource->id,
 | 
				
			||||||
                           SPA_RESULT_NO_MEMORY,
 | 
					                           SPA_RESULT_NO_MEMORY,
 | 
				
			||||||
| 
						 | 
					@ -195,6 +199,7 @@ core_create_client_node (void          *object,
 | 
				
			||||||
  return;
 | 
					  return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
no_mem:
 | 
					no_mem:
 | 
				
			||||||
 | 
					  pinos_log_error ("can't create client node");
 | 
				
			||||||
  pinos_core_notify_error (client->core_resource,
 | 
					  pinos_core_notify_error (client->core_resource,
 | 
				
			||||||
                           resource->id,
 | 
					                           resource->id,
 | 
				
			||||||
                           SPA_RESULT_NO_MEMORY,
 | 
					                           SPA_RESULT_NO_MEMORY,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -760,6 +760,7 @@ link_bind_func (PinosGlobal *global,
 | 
				
			||||||
  return SPA_RESULT_OK;
 | 
					  return SPA_RESULT_OK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
no_mem:
 | 
					no_mem:
 | 
				
			||||||
 | 
					  pinos_log_error ("can't create link resource");
 | 
				
			||||||
  pinos_core_notify_error (client->core_resource,
 | 
					  pinos_core_notify_error (client->core_resource,
 | 
				
			||||||
                           client->core_resource->id,
 | 
					                           client->core_resource->id,
 | 
				
			||||||
                           SPA_RESULT_NO_MEMORY,
 | 
					                           SPA_RESULT_NO_MEMORY,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -115,6 +115,7 @@ module_bind_func (PinosGlobal *global,
 | 
				
			||||||
  return SPA_RESULT_OK;
 | 
					  return SPA_RESULT_OK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
no_mem:
 | 
					no_mem:
 | 
				
			||||||
 | 
					  pinos_log_error ("can't create module resource");
 | 
				
			||||||
  pinos_core_notify_error (client->core_resource,
 | 
					  pinos_core_notify_error (client->core_resource,
 | 
				
			||||||
                           client->core_resource->id,
 | 
					                           client->core_resource->id,
 | 
				
			||||||
                           SPA_RESULT_NO_MEMORY,
 | 
					                           SPA_RESULT_NO_MEMORY,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -443,6 +443,7 @@ node_bind_func (PinosGlobal *global,
 | 
				
			||||||
  return SPA_RESULT_OK;
 | 
					  return SPA_RESULT_OK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
no_mem:
 | 
					no_mem:
 | 
				
			||||||
 | 
					  pinos_log_error ("can't create node resource");
 | 
				
			||||||
  pinos_core_notify_error (client->core_resource,
 | 
					  pinos_core_notify_error (client->core_resource,
 | 
				
			||||||
                           client->core_resource->id,
 | 
					                           client->core_resource->id,
 | 
				
			||||||
                           SPA_RESULT_NO_MEMORY,
 | 
					                           SPA_RESULT_NO_MEMORY,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,6 +51,7 @@ pinos_resource_new (PinosClient *client,
 | 
				
			||||||
  pinos_signal_init (&this->destroy_signal);
 | 
					  pinos_signal_init (&this->destroy_signal);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!pinos_map_insert_at (&client->objects, this->id, this)) {
 | 
					  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);
 | 
					    free (impl);
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue