[PATCH weston] compositor: do clean-up on init failure
Pekka Paalanen
ppaalanen at gmail.com
Mon Jul 30 06:56:57 PDT 2012
Simply exit(1)'ing the program will leave the VT unusable, since
DRM backend's clean-up does not run.
After a backend has been initialised, prefer jumping to clean-up instead
of directly exiting.
This fixes the case where 'weston-launch -- -i 5' would leave the
console unusable.
Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
src/compositor.c | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index 746ff85..c659527 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3489,14 +3489,16 @@ int main(int argc, char *argv[])
ec = backend_init(display, argc, argv, config_file);
if (ec == NULL) {
- weston_log("failed to create compositor\n");
+ weston_log("fatal: failed to create compositor\n");
exit(EXIT_FAILURE);
}
for (i = 1; argv[i]; i++)
- weston_log("unhandled option: %s\n", argv[i]);
- if (argv[1])
- exit(EXIT_FAILURE);
+ weston_log("fatal: unhandled option: %s\n", argv[i]);
+ if (argv[1]) {
+ ret = EXIT_FAILURE;
+ goto out;
+ }
free(config_file);
@@ -3508,25 +3510,32 @@ int main(int argc, char *argv[])
module_init = load_module("xwayland.so",
"weston_xserver_init",
&xserver_module);
- if (module_init && module_init(ec) < 0)
- exit(EXIT_FAILURE);
+ if (module_init && module_init(ec) < 0) {
+ ret = EXIT_FAILURE;
+ goto out;
+ }
if (!shell)
shell = "desktop-shell.so";
module_init = load_module(shell, "shell_init", &shell_module);
- if (!module_init || module_init(ec) < 0)
- exit(EXIT_FAILURE);
+ if (!module_init || module_init(ec) < 0) {
+ ret = EXIT_FAILURE;
+ goto out;
+ }
module_init = NULL;
if (module)
module_init = load_module(module, "module_init", NULL);
- if (module_init && module_init(ec) < 0)
- exit(EXIT_FAILURE);
+ if (module_init && module_init(ec) < 0) {
+ ret = EXIT_FAILURE;
+ goto out;
+ }
if (wl_display_add_socket(display, socket_name)) {
- weston_log("failed to add socket: %m\n");
- exit(EXIT_FAILURE);
+ weston_log("fatal: failed to add socket: %m\n");
+ ret = EXIT_FAILURE;
+ goto out;
}
weston_compositor_dpms_on(ec);
@@ -3536,6 +3545,7 @@ int main(int argc, char *argv[])
else
ret = EXIT_FAILURE;
+out:
/* prevent further rendering while shutting down */
ec->state = WESTON_COMPOSITOR_SLEEPING;
--
1.7.8.6
More information about the wayland-devel
mailing list