[PULL/RFC] compositor-x11 destructors v1

Pekka Paalanen ppaalanen at gmail.com
Tue Jan 3 06:53:18 PST 2012


here is the majority of the compositor cleanups I did for
compositor-x11. They depend on the patch "server: add
wl_input_device_fini()" to the Wayland core.

Most of it is trivial, but destroying global objects (input device,
maybe outputs) have their caveats. The main thing still not destroyed
after this patch set are the wl_client structures for clients that
exist at the time the compositor shuts down. I tried to destroy all
clients within wl_display_destroy(), but that does not work together
with destroying the global objects at backend shutdown time. The
client structures will hold references to objects the backend has
destroyed, so destroying the client hits use-after-free.

I guess solving that properly requires a proper implementation of
global object destructors, that not only announces the globals going
away to the clients, but also takes care of the corresponding
wl_resource objects, and the possible races between sending a destroy
event and a client processing it.

If you want, you can drop the compositor-x11 patches for now, they are
the ones that (are supposed to) destroy globals. In my tests, they did
not cause any harm, though, as we do not destroy the remaining

Do you have a plan on how to handle removing global objects dynamically,
e.g. an input device?

The following changes since commit f258a310bf1709729829f0090c3a5e460f9434e3:

  Fix WL_EVENT_WRITEABLE typo (2011-12-28 22:51:20 -0500)

are available in the git repository at:
  git://git.collabora.co.uk/git/user/pq/wayland-demos.git compositor-dtors-v1

Pekka Paalanen (14):
      compositor: add destructors to shell plugins
      compositor: free regions in wlsc_output_repaint()
      compositor: destroy all input binding objects on shutdown
      shell: destroy desktop_shell client on exit
      compositor: avoid scheduling rendering on shutdown
      compositor: clean up signal event sources on exit
      compositor: more cleanup on shutdown
      compositor: add wlsc_input_device_fini()
      compositor: free region members on surface destroy
      compositor: remove unused member from wlsc_input_device
      compositor: add screenshooter destructor
      compositor: fix use after free in wlsc_zoom_frame
      compositor-x11: implement x11_output_destroy()
      compositor-x11: improve x11_destroy()

 compositor/compositor-x11.c |   47 ++++++++++++++++++++++++++++++++++-
 compositor/compositor.c     |   56 ++++++++++++++++++++++++++++++++++++++----
 compositor/compositor.h     |   17 +++++++++++-
 compositor/screenshooter.c  |   21 ++++++++++++----
 compositor/shell.c          |   19 ++++++++++----
 compositor/tablet-shell.c   |   11 ++++++++
 compositor/util.c           |   13 +++++++++-
 7 files changed, 163 insertions(+), 21 deletions(-)

- pq

More information about the wayland-devel mailing list