[pulseaudio-discuss] [PATCH] mainloop: Run defer events in the order they are created
David Henningsson
david.henningsson at canonical.com
Tue Mar 18 04:11:15 PDT 2014
On 03/18/2014 09:23 AM, Tanu Kaskinen wrote:
> module-zeroconf-publish assumes that if it creates two defer events,
> then the one that was created first will be dispatched first. That's
> a fair assumption in my opinion, so let's fix the ordering in
> pa_mainloop.
Are you sure there are no modules assuming the current behaviour, and
thus will be broken with this patch?
>
> BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=76184
> ---
> src/pulse/mainloop.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c
> index 66a1475..e5fbc66 100644
> --- a/src/pulse/mainloop.c
> +++ b/src/pulse/mainloop.c
> @@ -98,6 +98,7 @@ struct pa_mainloop {
> PA_LLIST_HEAD(pa_io_event, io_events);
> PA_LLIST_HEAD(pa_time_event, time_events);
> PA_LLIST_HEAD(pa_defer_event, defer_events);
> + pa_defer_event *defer_events_tail;
>
> unsigned n_enabled_defer_events, n_enabled_time_events, n_io_events;
> unsigned io_events_please_scan, time_events_please_scan, defer_events_please_scan;
> @@ -245,7 +246,8 @@ static pa_defer_event* mainloop_defer_new(
> e->callback = callback;
> e->userdata = userdata;
>
> - PA_LLIST_PREPEND(pa_defer_event, m->defer_events, e);
> + PA_LLIST_INSERT_AFTER(pa_defer_event, m->defer_events, m->defer_events_tail, e);
> + m->defer_events_tail = e;
>
> pa_mainloop_wakeup(e->mainloop);
>
> @@ -547,6 +549,9 @@ static void cleanup_defer_events(pa_mainloop *m, bool force) {
> break;
>
> if (force || e->dead) {
> + if (e == m->defer_events_tail)
> + m->defer_events_tail = e->prev;
> +
> PA_LLIST_REMOVE(pa_defer_event, m->defer_events, e);
>
> if (e->dead) {
>
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
More information about the pulseaudio-discuss
mailing list