[gvfs] metadata: Export skeleton before name is acquired
- From: Ross Lagerwall <rossl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] metadata: Export skeleton before name is acquired
- Date: Sat, 31 Jan 2015 10:24:37 +0000 (UTC)
commit 808b6cf892ec2a50b70cfee4a56c68795ba4a6fc
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Wed Jan 28 23:09:43 2015 +0000
metadata: Export skeleton before name is acquired
Exporting the skeleton after acquiring the name is racy, as documented
in the GIO docs for g_bus_own_name.
https://bugzilla.gnome.org/show_bug.cgi?id=743653
metadata/meta-daemon.c | 45 +++++++++++++++++++--------------------------
1 files changed, 19 insertions(+), 26 deletions(-)
---
diff --git a/metadata/meta-daemon.c b/metadata/meta-daemon.c
index 73d407d..9572940 100644
--- a/metadata/meta-daemon.c
+++ b/metadata/meta-daemon.c
@@ -419,31 +419,6 @@ handle_move (GVfsMetadata *object,
}
static void
-on_name_acquired (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- GError *error;
-
- skeleton = gvfs_metadata_skeleton_new ();
-
- g_signal_connect (skeleton, "handle-set", G_CALLBACK (handle_set), skeleton);
- g_signal_connect (skeleton, "handle-unset", G_CALLBACK (handle_unset), skeleton);
- g_signal_connect (skeleton, "handle-get", G_CALLBACK (handle_get), skeleton);
- g_signal_connect (skeleton, "handle-remove", G_CALLBACK (handle_remove), skeleton);
- g_signal_connect (skeleton, "handle-move", G_CALLBACK (handle_move), skeleton);
-
- error = NULL;
- if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton), connection,
- G_VFS_DBUS_METADATA_PATH, &error))
- {
- g_printerr ("Error exporting volume monitor: %s (%s, %d)\n",
- error->message, g_quark_to_string (error->domain), error->code);
- g_error_free (error);
- }
-}
-
-static void
on_name_lost (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
@@ -549,10 +524,28 @@ main (int argc, char *argv[])
if (replace)
flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE;
+ skeleton = gvfs_metadata_skeleton_new ();
+
+ g_signal_connect (skeleton, "handle-set", G_CALLBACK (handle_set), skeleton);
+ g_signal_connect (skeleton, "handle-unset", G_CALLBACK (handle_unset), skeleton);
+ g_signal_connect (skeleton, "handle-get", G_CALLBACK (handle_get), skeleton);
+ g_signal_connect (skeleton, "handle-remove", G_CALLBACK (handle_remove), skeleton);
+ g_signal_connect (skeleton, "handle-move", G_CALLBACK (handle_move), skeleton);
+
+ error = NULL;
+ if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton), conn,
+ G_VFS_DBUS_METADATA_PATH, &error))
+ {
+ g_printerr ("Error exporting metadata daemon: %s (%s, %d)\n",
+ error->message, g_quark_to_string (error->domain), error->code);
+ g_error_free (error);
+ return 1;
+ }
+
name_owner_id = g_bus_own_name_on_connection (conn,
G_VFS_DBUS_METADATA_NAME,
flags,
- on_name_acquired,
+ NULL,
on_name_lost,
loop,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]