From 828048bfb4561c232dc668897f8203a3540edb0e Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 6 Sep 2019 03:33:51 +0200 Subject: [PATCH 1/3] at-spi-bus-launcher: clear a11y_bus_pid when failing to read address This may happen if dbus-daemon spawns but fails to start. In that case after terminating it we should forget its pid, to avoid trying to terminate it again at the end of main(). --- bus/at-spi-bus-launcher.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c index 6cb625c..57727c1 100644 --- a/bus/at-spi-bus-launcher.c +++ b/bus/at-spi-bus-launcher.c @@ -323,6 +323,7 @@ ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path) { app->a11y_launch_error_message = g_strdup_printf ("Failed to read address: %s", strerror (errno)); kill (app->a11y_bus_pid, SIGTERM); + app->a11y_bus_pid = -1; goto error; } close (app->pipefd[0]); -- 2.22.0 From 1e43ac742c7622beaa40902777a017efa3af2402 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 6 Sep 2019 03:39:30 +0200 Subject: [PATCH 2/3] at-spi-bus-launcher: Only clear AT_SPI_BUS X prop when having set it In case where bus name acquisition fails, we shall not drop the AT_SPI_BUS X property of the existing daemon. --- bus/at-spi-bus-launcher.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c index 57727c1..af85f04 100644 --- a/bus/at-spi-bus-launcher.c +++ b/bus/at-spi-bus-launcher.c @@ -63,6 +63,9 @@ typedef struct { /* -1 == error, 0 == pending, > 0 == running */ int a11y_bus_pid; char *a11y_bus_address; +#ifdef HAVE_X11 + gboolean x11_prop_set; +#endif int pipefd[2]; int listenfd; char *a11y_launch_error_message; @@ -480,6 +483,7 @@ ensure_a11y_bus (A11yBusLauncher *app) (guchar *) app->a11y_bus_address, strlen (app->a11y_bus_address)); XFlush (display); XCloseDisplay (display); + app->x11_prop_set = TRUE; } } #endif @@ -886,7 +890,7 @@ main (int argc, * we don't want early login processes to pick up the stale address. */ #ifdef HAVE_X11 - if (g_getenv ("DISPLAY") != NULL && g_getenv ("WAYLAND_DISPLAY") == NULL) + if (_global_app->x11_prop_set) { Display *display = XOpenDisplay (NULL); if (display) -- 2.22.0 From 018443b7a8ad0b6f068c2255adcb49037a388d15 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 6 Sep 2019 03:40:53 +0200 Subject: [PATCH 3/3] at-spi-bus-launcher: defer starting atspi bus after bus name acquired In case bus name acquisition fails, we should not have started a bus after all, but worse, we should not have written its address in the AT_SPI_BUS X root property. We should thus do them only after having acquired the bus name. --- bus/at-spi-bus-launcher.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c index af85f04..b4f49b8 100644 --- a/bus/at-spi-bus-launcher.c +++ b/bus/at-spi-bus-launcher.c @@ -683,16 +683,6 @@ on_bus_acquired (GDBusConnection *connection, } app->session_bus = connection; - if (app->launch_immediately) - { - ensure_a11y_bus (app); - if (app->state == A11Y_BUS_STATE_ERROR) - { - g_main_loop_quit (app->loop); - return; - } - } - error = NULL; registration_id = g_dbus_connection_register_object (connection, "/org/a11y/bus", @@ -734,6 +724,18 @@ on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { + A11yBusLauncher *app = user_data; + + if (app->launch_immediately) + { + ensure_a11y_bus (app); + if (app->state == A11Y_BUS_STATE_ERROR) + { + g_main_loop_quit (app->loop); + return; + } + } + g_bus_watch_name (G_BUS_TYPE_SESSION, "org.gnome.SessionManager", G_BUS_NAME_WATCHER_FLAGS_NONE, -- 2.22.0