From c474846c42967c44db069a23b76a29da6f496f33 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 8 Feb 2022 10:18:02 +0100 Subject: [PATCH] loop: remove destroy list Now that sources can't be dispatched anymore after a _remove, we don't need to keep the destroy_list anymore and we can free the source immediately. See #2114 --- spa/plugins/support/loop.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/spa/plugins/support/loop.c b/spa/plugins/support/loop.c index 2e6c35c1c..7205f7581 100644 --- a/spa/plugins/support/loop.c +++ b/spa/plugins/support/loop.c @@ -75,7 +75,6 @@ struct impl { struct spa_system *system; struct spa_list source_list; - struct spa_list destroy_list; struct spa_hook_list hooks_list; int poll_fd; @@ -309,14 +308,6 @@ static void loop_leave(void *object) impl->thread = 0; } -static inline void process_destroy(struct impl *impl) -{ - struct source_impl *source, *tmp; - spa_list_for_each_safe(source, tmp, &impl->destroy_list, link) - free(source); - spa_list_init(&impl->destroy_list); -} - static int loop_iterate(void *object, int timeout) { struct impl *impl = object; @@ -346,9 +337,6 @@ static int loop_iterate(void *object, int timeout) if (SPA_LIKELY(s && s->rmask)) s->func(s); } - if (SPA_UNLIKELY(!spa_list_is_empty(&impl->destroy_list))) - process_destroy(impl); - impl->n_dispatching = 0; return nfds; } @@ -703,7 +691,7 @@ static void loop_destroy_source(void *object, struct spa_source *source) spa_system_close(impl->impl->system, source->fd); source->fd = -1; } - spa_list_insert(&impl->impl->destroy_list, &impl->link); + free(source); } static const struct spa_loop_methods impl_loop = { @@ -770,8 +758,6 @@ static int impl_clear(struct spa_handle *handle) spa_list_consume(source, &impl->source_list, link) loop_destroy_source(impl, &source->source); - process_destroy(impl); - spa_system_close(impl->system, impl->ack_fd); spa_system_close(impl->system, impl->poll_fd); @@ -833,7 +819,6 @@ impl_init(const struct spa_handle_factory *factory, impl->poll_fd = res; spa_list_init(&impl->source_list); - spa_list_init(&impl->destroy_list); spa_hook_list_init(&impl->hooks_list); impl->buffer_data = SPA_PTR_ALIGN(impl->buffer_mem, MAX_ALIGN, uint8_t);