[PATCH weston] simple-egl: Avoid race condition.
Kristian Høgsberg
hoegsberg at gmail.com
Fri Aug 31 16:50:15 PDT 2012
On Fri, Aug 31, 2012 at 03:18:15AM -0600, Scott Moreau wrote:
> After explaining the problem on irc, Pekka dictated this solution which works.
> The problem is that simple-egl can hang when toggling fullscreen because of a
> race where (quoting Pekka) "if it dispatches the frame callback simple-egl
> itself requested before the Mesa's own frame callback came, simple-egl will go
> to its redraw routing and call eglSwapBuffers so you end up effectively calling
> eglSwapBuffers from within eglSwapBuffers, and deadlock". This patch avoids
> redrawing (which calls eglSwapBuffers) when there is a pending frame callback.
Right, sure. We really need to fix the eglSwapBuffer problem though,
it's been there for way too long.
Kristian
> ---
> clients/simple-egl.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/clients/simple-egl.c b/clients/simple-egl.c
> index c52c82c..de93e09 100644
> --- a/clients/simple-egl.c
> +++ b/clients/simple-egl.c
> @@ -264,7 +264,9 @@ configure_callback(void *data, struct wl_callback *callback, uint32_t time)
> wl_callback_destroy(callback);
>
> window->configured = 1;
> - redraw(data, NULL, time);
> +
> + if (window->callback == NULL)
> + redraw(data, NULL, time);
> }
>
> static struct wl_callback_listener configure_callback_listener = {
> @@ -363,6 +365,9 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
> static uint32_t start_time = 0;
> struct wl_region *region;
>
> + assert(window->callback == callback);
> + window->callback = NULL;
> +
> if (callback)
> wl_callback_destroy(callback);
>
> --
> 1.7.11.4
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list