[glib/glib-2-62: 5/10] gdbusserver: Delete socket and nonce file when stopping server
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-62: 5/10] gdbusserver: Delete socket and nonce file when stopping server
- Date: Thu, 31 Oct 2019 14:02:11 +0000 (UTC)
commit 30b7623e1ee4e5ef2d7a50f9a0936934c9737636
Author: Philip Withnall <withnall endlessm com>
Date: Mon Oct 28 20:42:19 2019 +0000
gdbusserver: Delete socket and nonce file when stopping server
Rather than when finalising it. They should be automatically recreated
if the server is re-started.
This is important for ensuring that all externally visible behaviour of
the `GDBusServer` is synchronised with calls to
g_dbus_server_{start,stop}(). Finalisation of the server object could
happen an arbitrarily long time after g_dbus_server_stop() is called.
Signed-off-by: Philip Withnall <withnall endlessm com>
Helps: #1318
gio/gdbusserver.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/gio/gdbusserver.c b/gio/gdbusserver.c
index 26f8dadd0..377ad4456 100644
--- a/gio/gdbusserver.c
+++ b/gio/gdbusserver.c
@@ -179,6 +179,8 @@ g_dbus_server_finalize (GObject *object)
{
GDBusServer *server = G_DBUS_SERVER (object);
+ g_assert (!server->active);
+
if (server->authentication_observer != NULL)
g_object_unref (server->authentication_observer);
@@ -197,19 +199,8 @@ g_dbus_server_finalize (GObject *object)
g_free (server->nonce);
}
- if (server->unix_socket_path)
- {
- if (g_unlink (server->unix_socket_path) != 0)
- g_warning ("Failed to delete %s: %s", server->unix_socket_path, g_strerror (errno));
- g_free (server->unix_socket_path);
- }
-
- if (server->nonce_file)
- {
- if (g_unlink (server->nonce_file) != 0)
- g_warning ("Failed to delete %s: %s", server->nonce_file, g_strerror (errno));
- g_free (server->nonce_file);
- }
+ g_free (server->unix_socket_path);
+ g_free (server->nonce_file);
g_main_context_unref (server->main_context_at_construction);
@@ -648,6 +639,18 @@ g_dbus_server_stop (GDBusServer *server)
g_socket_service_stop (G_SOCKET_SERVICE (server->listener));
server->active = FALSE;
g_object_notify (G_OBJECT (server), "active");
+
+ if (server->unix_socket_path)
+ {
+ if (g_unlink (server->unix_socket_path) != 0)
+ g_warning ("Failed to delete %s: %s", server->unix_socket_path, g_strerror (errno));
+ }
+
+ if (server->nonce_file)
+ {
+ if (g_unlink (server->nonce_file) != 0)
+ g_warning ("Failed to delete %s: %s", server->nonce_file, g_strerror (errno));
+ }
}
/* ---------------------------------------------------------------------------------------------------- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]