From 7e9fc5bff35eced62167417b1b3b273c5a641d3c Mon Sep 17 00:00:00 2001 From: Mike Gorse Date: Mon, 14 Apr 2014 15:21:24 -0500 Subject: Add an atexit handler to remove the D-Bus socket We should try not to leave stale sockets and their directories when exiting. They are removed when calling atk_bridge_adaptor_cleanup, but gtk does not currently call this function when exiting, and there is not a good place to call it from gtk. https://bugzilla.gnome.org/show_bug.cgi?id=684076 --- atk-adaptor/bridge.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c index aeabb91..2da29a7 100644 --- a/atk-adaptor/bridge.c +++ b/atk-adaptor/bridge.c @@ -57,6 +57,7 @@ signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data); SpiBridge *spi_global_app_data = NULL; static gboolean inited = FALSE; +static gboolean atexit_added = FALSE; /*---------------------------------------------------------------------------*/ @@ -445,6 +446,27 @@ register_application (SpiBridge * app) /*---------------------------------------------------------------------------*/ +static void +remove_socket () +{ + if (!spi_global_app_data) + return; + + if (spi_global_app_data->app_bus_addr) + { + unlink (spi_global_app_data->app_bus_addr); + g_free (spi_global_app_data->app_bus_addr); + spi_global_app_data->app_bus_addr = NULL; + } + + if (spi_global_app_data->app_tmp_dir) + { + rmdir (spi_global_app_data->app_tmp_dir); + g_free (spi_global_app_data->app_tmp_dir); + spi_global_app_data->app_tmp_dir = NULL; + } +} + static void deregister_application (SpiBridge * app) { @@ -466,19 +488,7 @@ deregister_application (SpiBridge * app) if (message) dbus_message_unref (message); - if (app->app_bus_addr) - { - unlink (app->app_bus_addr); - g_free (app->app_bus_addr); - app->app_bus_addr = NULL; - } - - if (app->app_tmp_dir) - { - rmdir (app->app_tmp_dir); - g_free (app->app_tmp_dir); - app->app_tmp_dir = NULL; - } + remove_socket (); g_free (app->desktop_name); app->desktop_name = NULL; @@ -1091,6 +1101,10 @@ atk_bridge_adaptor_init (gint * argc, gchar ** argv[]) else get_registered_event_listeners (spi_global_app_data); + if (!atexit_added) + atexit (remove_socket); + atexit_added = TRUE; + dbus_error_free (&error); return 0; } -- cgit v1.2.1