[PATCH] Shutdown the compositor before removing graphics

Ander Conselvan de Oliveira conselvan2 at gmail.com
Tue Nov 5 07:13:17 PST 2013


On 11/04/2013 10:39 AM, Cameron Stewart wrote:
> Otherwise the outputs are removed when they have already
> been freed. However don't clean up the debug listeners in gl_renderer
> as these would be cleaned up by the compositor previously.

I'm not sure why I didn't notice the error when I wrote the patch that 
changed the order. If I understood correctly the problem is that 
gl_renderer_destroy_output() is called after the renderer is destroyed 
and that causes a crash trying to access ec->renderer.

The point of that series was to get to a point where we can destroy a 
renderer in runtime and make sure everything is cleaned up, so I rather 
fix this some other way. We have a call to ec->renderer->destroy() in 
every backend, so perhaps we can move that into 
weston_compositor_shutdown() just after the outputs are destroyed.

Thanks,
Ander

> ---
>   src/compositor-drm.c     | 4 ++--
>   src/compositor-rdp.c     | 2 +-
>   src/compositor-rpi.c     | 4 ++--
>   src/compositor-wayland.c | 4 ++--
>   src/compositor-x11.c     | 4 ++--
>   src/gl-renderer.c        | 4 ++--
>   6 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index 3bdc20b..cced27d 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -2328,10 +2328,10 @@ drm_destroy(struct weston_compositor *ec)
>
>   	destroy_sprites(d);
>
> -	ec->renderer->destroy(ec);
> -
>   	weston_compositor_shutdown(ec);
>
> +	ec->renderer->destroy(ec);
> +
>   	if (d->gbm)
>   		gbm_device_destroy(d->gbm);
>
> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
> index 8a302f8..36aa690 100644
> --- a/src/compositor-rdp.c
> +++ b/src/compositor-rdp.c
> @@ -523,8 +523,8 @@ rdp_restore(struct weston_compositor *ec)
>   static void
>   rdp_destroy(struct weston_compositor *ec)
>   {
> -	ec->renderer->destroy(ec);
>   	weston_compositor_shutdown(ec);
> +	ec->renderer->destroy(ec);
>
>   	free(ec);
>   }
> diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
> index f163e01..a1c14e2 100644
> --- a/src/compositor-rpi.c
> +++ b/src/compositor-rpi.c
> @@ -652,11 +652,11 @@ rpi_compositor_destroy(struct weston_compositor *base)
>   	wl_list_for_each_safe(seat, next, &compositor->base.seat_list, link)
>   		evdev_input_destroy(seat);
>
> -	compositor->base.renderer->destroy(&compositor->base);
> -
>   	/* destroys outputs, too */
>   	weston_compositor_shutdown(&compositor->base);
>
> +	compositor->base.renderer->destroy(&compositor->base);
> +
>   	weston_launcher_destroy(compositor->base.launcher);
>
>   	bcm_host_deinit();
> diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
> index d626ee1..3ca3d6b 100644
> --- a/src/compositor-wayland.c
> +++ b/src/compositor-wayland.c
> @@ -715,10 +715,10 @@ wayland_destroy(struct weston_compositor *ec)
>   {
>   	struct wayland_compositor *c = (struct wayland_compositor *) ec;
>
> -	ec->renderer->destroy(ec);
> -
>   	weston_compositor_shutdown(ec);
>
> +	ec->renderer->destroy(ec);
> +
>   	if (c->parent.shm)
>   		wl_shm_destroy(c->parent.shm);
>
> diff --git a/src/compositor-x11.c b/src/compositor-x11.c
> index 73e71ed..d045e9d 100644
> --- a/src/compositor-x11.c
> +++ b/src/compositor-x11.c
> @@ -1445,10 +1445,10 @@ x11_destroy(struct weston_compositor *ec)
>   	wl_event_source_remove(compositor->xcb_source);
>   	x11_input_destroy(compositor);
>
> -	ec->renderer->destroy(ec);
> -
>   	weston_compositor_shutdown(ec); /* destroys outputs, too */
>
> +	ec->renderer->destroy(ec);
> +
>   	XCloseDisplay(compositor->dpy);
>   	free(ec);
>   }
> diff --git a/src/gl-renderer.c b/src/gl-renderer.c
> index d181c07..29191d5 100644
> --- a/src/gl-renderer.c
> +++ b/src/gl-renderer.c
> @@ -1630,8 +1630,8 @@ gl_renderer_destroy(struct weston_compositor *ec)
>   	wl_array_release(&gr->indices);
>   	wl_array_release(&gr->vtxcnt);
>
> -	weston_binding_destroy(gr->fragment_binding);
> -	weston_binding_destroy(gr->fan_binding);
> +	/* We would normally remove the bindings here but they should have
> +	 * already been removed when the compositor shutdown */
>
>   	free(gr);
>   }
>



More information about the wayland-devel mailing list