[PATCH] mainloop, glib-mainloop: time_restart could cause incorrect event ordering

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,
     I sent this patch a few months ago, could someone take a look at it?

Thanks,
Ben

On 25/07/13 13:44, Ben Brewer wrote:
> From: Ben Brewer <benbrewer at codethink.co.uk>
>
> This fixes a bug where calling time_restart can leave the current event
> in the cache, even though the restart scheduled the event in the future.
> This would cause the event to get executed more frequently than it should.
> ---
>   src/pulse/glib-mainloop.c |    6 ++++--
>   src/pulse/mainloop.c      |    6 ++++--
>   2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/src/pulse/glib-mainloop.c b/src/pulse/glib-mainloop.c
> index bd24913..34f3556 100644
> --- a/src/pulse/glib-mainloop.c
> +++ b/src/pulse/glib-mainloop.c
> @@ -328,13 +328,15 @@ static void glib_time_restart(pa_time_event*e, const struct timeval *tv) {
>       if ((e->enabled = !!tv))
>           e->timeval = *tv;
>   
> +    if (e->mainloop->cached_next_time_event == e)
> +        e->mainloop->cached_next_time_event = NULL;
> +
>       if (e->mainloop->cached_next_time_event && e->enabled) {
>           g_assert(e->mainloop->cached_next_time_event->enabled);
>   
>           if (pa_timeval_cmp(tv, &e->mainloop->cached_next_time_event->timeval) < 0)
>               e->mainloop->cached_next_time_event = e;
> -    } else if (e->mainloop->cached_next_time_event == e)
> -        e->mainloop->cached_next_time_event = NULL;
> +    }
>   }
>   
>   static void glib_time_free(pa_time_event *e) {
> diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c
> index 60fbbb9..0e1fba0 100644
> --- a/src/pulse/mainloop.c
> +++ b/src/pulse/mainloop.c
> @@ -379,13 +379,15 @@ static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) {
>           pa_mainloop_wakeup(e->mainloop);
>       }
>   
> +    if (e->mainloop->cached_next_time_event == e)
> +        e->mainloop->cached_next_time_event = NULL;
> +
>       if (e->mainloop->cached_next_time_event && e->enabled) {
>           pa_assert(e->mainloop->cached_next_time_event->enabled);
>   
>           if (t < e->mainloop->cached_next_time_event->time)
>               e->mainloop->cached_next_time_event = e;
> -    } else if (e->mainloop->cached_next_time_event == e)
> -        e->mainloop->cached_next_time_event = NULL;
> +    }
>   }
>   
>   static void mainloop_time_free(pa_time_event *e) {



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux