shell: Handle the desktop shell client destroy signal
authorAnder Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Fri, 20 Dec 2013 19:07:01 +0000 (21:07 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Sun, 22 Dec 2013 21:45:36 +0000 (13:45 -0800)
Set the internal pointer for the client to NULL. This fixes a
segmentation fault at shutdown, where the shell would hang up before
and cause libwayland to call wl_client_destroy(). When the shell was
destroyed later, another call to wl_client_destroy() would cause the
crash.

https://bugs.freedesktop.org/show_bug.cgi?id=72550

desktop-shell/shell.c
desktop-shell/shell.h

index 3d586ec..714881b 100644 (file)
@@ -5008,6 +5008,17 @@ desktop_shell_sigchld(struct weston_process *process, int status)
 }
 
 static void
+desktop_shell_client_destroy(struct wl_listener *listener, void *data)
+{
+       struct desktop_shell *shell;
+
+       shell = container_of(listener, struct desktop_shell,
+                            child.client_destroy_listener);
+
+       shell->child.client = NULL;
+}
+
+static void
 launch_desktop_shell_process(void *data)
 {
        struct desktop_shell *shell = data;
@@ -5019,6 +5030,11 @@ launch_desktop_shell_process(void *data)
 
        if (!shell->child.client)
                weston_log("not able to start %s\n", shell->client);
+
+       shell->child.client_destroy_listener.notify =
+               desktop_shell_client_destroy;
+       wl_client_add_destroy_listener(shell->child.client,
+                                      &shell->child.client_destroy_listener);
 }
 
 static void
index d7c34fc..7a8194d 100644 (file)
@@ -92,6 +92,7 @@ struct desktop_shell {
                struct weston_process process;
                struct wl_client *client;
                struct wl_resource *desktop_shell;
+               struct wl_listener client_destroy_listener;
 
                unsigned deathcount;
                uint32_t deathstamp;