summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2015-04-23 10:26:38 -0400
committerRay Strode <rstrode@redhat.com>2015-04-23 13:51:11 -0400
commit40cccb58a5084a970265fb55df9aad69dc81b39e (patch)
tree223466265ea7d12c9763dce16eabcb3404176e2b
parenteb6c70137b6d7c7b347148c89b33446dba5991c6 (diff)
xwayland: use out label for cleanup in start function
The start function has a few exit paths that need to perform clean up of the lock file. This commit consolidates those exit paths at the end using an out label and gotos. https://bugzilla.gnome.org/show_bug.cgi?id=748380
-rw-r--r--src/wayland/meta-xwayland.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 8d563de7..1f98445b 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -438,28 +438,27 @@ meta_xwayland_start (MetaXWaylandManager *manager,
{
int xwayland_client_fd[2];
int displayfd[2];
+ gboolean started = FALSE;
g_autoptr(GSubprocessLauncher) launcher = NULL;
GSubprocessFlags flags;
GSubprocess *proc;
GError *error = NULL;
if (!choose_xdisplay (manager))
- return FALSE;
+ goto out;
/* We want xwayland to be a wayland client so we make a socketpair to setup a
* wayland protocol connection. */
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, xwayland_client_fd) < 0)
{
g_warning ("xwayland_client_fd socketpair failed\n");
- unlink (manager->lockfile);
- return FALSE;
+ goto out;
}
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, displayfd) < 0)
{
g_warning ("displayfd socketpair failed\n");
- unlink (manager->lockfile);
- return FALSE;
+ goto out;
}
/* xwayland, please. */
@@ -489,7 +488,7 @@ meta_xwayland_start (MetaXWaylandManager *manager,
if (!proc)
{
g_error ("Failed to spawn Xwayland: %s", error->message);
- return FALSE;
+ goto out;
}
g_subprocess_wait_async (proc, NULL, xserver_died, NULL);
@@ -502,7 +501,12 @@ meta_xwayland_start (MetaXWaylandManager *manager,
manager->init_loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (manager->init_loop);
- return TRUE;
+ started = TRUE;
+
+out:
+ if (!started)
+ unlink (manager->lockfile);
+ return started;
}
/* To be called right after connecting */