mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	loop: warn when some queues are still in TSS
When we clear we need to have all our queues removed from the TSS when we delete the tss key or else they are leaked, check an warn about this using a refcount of queued in the TSS. See #4356
This commit is contained in:
		
							parent
							
								
									c4fece74a5
								
							
						
					
					
						commit
						bb53aa08ad
					
				
					 1 changed files with 8 additions and 0 deletions
				
			
		| 
						 | 
					@ -72,6 +72,7 @@ struct impl {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct spa_source *wakeup;
 | 
						struct spa_source *wakeup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int tss_ref;
 | 
				
			||||||
	tss_t queue_tss_id;
 | 
						tss_t queue_tss_id;
 | 
				
			||||||
	pthread_mutex_t queue_lock;
 | 
						pthread_mutex_t queue_lock;
 | 
				
			||||||
	uint32_t count;
 | 
						uint32_t count;
 | 
				
			||||||
| 
						 | 
					@ -432,6 +433,7 @@ static void loop_queue_destroy_tss(void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct queue *queue = data;
 | 
						struct queue *queue = data;
 | 
				
			||||||
	if (queue) {
 | 
						if (queue) {
 | 
				
			||||||
 | 
							SPA_ATOMIC_DEC(queue->impl->tss_ref);
 | 
				
			||||||
		loop_queue_destroy(queue);
 | 
							loop_queue_destroy(queue);
 | 
				
			||||||
		free(queue);
 | 
							free(queue);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -448,6 +450,7 @@ static int loop_invoke(void *object, spa_invoke_func_t func, uint32_t seq,
 | 
				
			||||||
		local_queue = loop_create_queue(impl, QUEUE_FLAG_ACK_FD | QUEUE_FLAG_IN_TSS);
 | 
							local_queue = loop_create_queue(impl, QUEUE_FLAG_ACK_FD | QUEUE_FLAG_IN_TSS);
 | 
				
			||||||
		if (local_queue == NULL)
 | 
							if (local_queue == NULL)
 | 
				
			||||||
			return -errno;
 | 
								return -errno;
 | 
				
			||||||
 | 
							SPA_ATOMIC_INC(impl->tss_ref);
 | 
				
			||||||
		tss_set(impl->queue_tss_id, local_queue);
 | 
							tss_set(impl->queue_tss_id, local_queue);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return loop_queue_invoke(local_queue, func, seq, data, size, block, user_data);
 | 
						return loop_queue_invoke(local_queue, func, seq, data, size, block, user_data);
 | 
				
			||||||
| 
						 | 
					@ -1101,6 +1104,10 @@ static int impl_clear(struct spa_handle *handle)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_system_close(impl->system, impl->poll_fd);
 | 
						spa_system_close(impl->system, impl->poll_fd);
 | 
				
			||||||
	pthread_mutex_destroy(&impl->queue_lock);
 | 
						pthread_mutex_destroy(&impl->queue_lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (SPA_ATOMIC_DEC(impl->tss_ref) != 0)
 | 
				
			||||||
 | 
							spa_log_warn(impl->log, "%p: loop still has %d queues in TSS",
 | 
				
			||||||
 | 
									impl, impl->tss_ref);
 | 
				
			||||||
	tss_delete(impl->queue_tss_id);
 | 
						tss_delete(impl->queue_tss_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -1197,6 +1204,7 @@ impl_init(const struct spa_handle_factory *factory,
 | 
				
			||||||
		spa_log_error(impl->log, "%p: can't create tss: %m", impl);
 | 
							spa_log_error(impl->log, "%p: can't create tss: %m", impl);
 | 
				
			||||||
		goto error_exit_free_wakeup;
 | 
							goto error_exit_free_wakeup;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						impl->tss_ref = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_log_debug(impl->log, "%p: initialized", impl);
 | 
						spa_log_debug(impl->log, "%p: initialized", impl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue