compositor: Fix wet_process cleanup on compositor shuwdown
authorMarius Vlad <marius.vlad@collabora.com>
Thu, 18 Apr 2024 12:02:56 +0000 (15:02 +0300)
committerMarius Vlad <marius.vlad@collabora.com>
Sat, 20 Apr 2024 14:15:33 +0000 (17:15 +0300)
Bug-AGL: PEC-5104
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: Ib57d93378847cf2c7fa07782d983a179fa4a7ce8

src/compositor.c
src/ivi-compositor.h
src/xwayland.c

index d82676b..1881702 100644 (file)
@@ -73,6 +73,16 @@ to_ivi_compositor(struct weston_compositor *ec)
        return weston_compositor_get_user_data(ec);
 }
 
+void
+ivi_process_destroy(struct wet_process *process, int status, bool call_cleanup)
+{
+        wl_list_remove(&process->link);
+        if (call_cleanup && process->cleanup)
+                process->cleanup(process, status, process->cleanup_data);
+        free(process->path);
+        free(process);
+}
+
 struct ivi_output_config *
 ivi_init_parsed_options(struct weston_compositor *compositor)
 {
@@ -2034,6 +2044,7 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da
        bool xwayland = false;
        struct sigaction action;
        char *renderer = NULL;
+       struct wet_process *process, *process_tmp;
 
        const struct weston_option core_options[] = {
                { WESTON_OPTION_STRING, "renderer", 'r', &renderer },
@@ -2252,6 +2263,9 @@ error_compositor:
 
        ivi_policy_destroy(ivi.policy);
 
+        wl_list_for_each_safe(process, process_tmp, &ivi.child_process_list, link)
+                ivi_process_destroy(process, 0, false);
+
 error_signals:
        for (size_t i = 0; i < ARRAY_LENGTH(signals); ++i)
                if (signals[i])
index 7afb0c9..1303e44 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdbool.h>
 #include "config.h"
 
+#include <weston.h>
 #include <libweston/backend-drm.h>
 #include <libweston/libweston.h>
 #include <libweston/windowed-output-api.h>
@@ -566,4 +567,7 @@ _ivi_set_shell_surface_split(struct ivi_surface *surface, struct ivi_output *out
 struct ivi_output_config *
 ivi_init_parsed_options(struct weston_compositor *compositor);
 
+void
+ivi_process_destroy(struct wet_process *process, int status, bool call_cleanup);
+
 #endif
index 229ce75..3bea411 100644 (file)
@@ -55,16 +55,6 @@ struct wet_xwayland {
        struct wet_process *process;
 };
 
-static void
-process_destroy(struct wet_process *process, int status, bool call_cleanup)
-{
-        wl_list_remove(&process->link);
-        if (call_cleanup && process->cleanup)
-                process->cleanup(process, status, process->cleanup_data);
-        free(process->path);
-        free(process);
-}
-
 static int
 handle_display_fd(int fd, uint32_t mask, void *data)
 {
@@ -337,7 +327,7 @@ wet_xwayland_destroy(struct weston_compositor *compositor, void *data)
        /* Calling this will call the process cleanup, in turn cleaning up the
         * client and the core Xwayland state */
        if (wxw->process)
-               process_destroy(wxw->process, 0, true);
+               ivi_process_destroy(wxw->process, 0, true);
 
        free(wxw);
 }