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
This commit is contained in:
Ray Strode 2015-04-23 10:26:38 -04:00
parent eb6c70137b
commit 40cccb58a5

View File

@ -438,28 +438,27 @@ meta_xwayland_start (MetaXWaylandManager *manager,
{ {
int xwayland_client_fd[2]; int xwayland_client_fd[2];
int displayfd[2]; int displayfd[2];
gboolean started = FALSE;
g_autoptr(GSubprocessLauncher) launcher = NULL; g_autoptr(GSubprocessLauncher) launcher = NULL;
GSubprocessFlags flags; GSubprocessFlags flags;
GSubprocess *proc; GSubprocess *proc;
GError *error = NULL; GError *error = NULL;
if (!choose_xdisplay (manager)) if (!choose_xdisplay (manager))
return FALSE; goto out;
/* We want xwayland to be a wayland client so we make a socketpair to setup a /* We want xwayland to be a wayland client so we make a socketpair to setup a
* wayland protocol connection. */ * wayland protocol connection. */
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, xwayland_client_fd) < 0) if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, xwayland_client_fd) < 0)
{ {
g_warning ("xwayland_client_fd socketpair failed\n"); g_warning ("xwayland_client_fd socketpair failed\n");
unlink (manager->lockfile); goto out;
return FALSE;
} }
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, displayfd) < 0) if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, displayfd) < 0)
{ {
g_warning ("displayfd socketpair failed\n"); g_warning ("displayfd socketpair failed\n");
unlink (manager->lockfile); goto out;
return FALSE;
} }
/* xwayland, please. */ /* xwayland, please. */
@ -489,7 +488,7 @@ meta_xwayland_start (MetaXWaylandManager *manager,
if (!proc) if (!proc)
{ {
g_error ("Failed to spawn Xwayland: %s", error->message); g_error ("Failed to spawn Xwayland: %s", error->message);
return FALSE; goto out;
} }
g_subprocess_wait_async (proc, NULL, xserver_died, NULL); 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); manager->init_loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (manager->init_loop); 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 */ /* To be called right after connecting */