GNOME Bugzilla – Bug 743653
race condition when registering mount tracker skeleton
Last modified: 2015-02-02 14:41:02 UTC
Created attachment 295674 [details] [review] register mount tracker skeleton by bus_acquired_handler Mount tracker skeleton is registered by name_acquired_handler of g_bus_own_name currently, however this is too late probably. Therefore e.g. mount operation could fail for the first time with the following error: No such interface `org.gtk.vfs.MountTracker' on object at path /org/gtk/vfs/mounttracker I think it is problem which is mentioned in the documentation for g_bus_own_name: "If you plan on exporting objects (using e.g. g_dbus_connection_register_object()), note that it is generally too late to export the objects in name_acquired_handler . Instead, you can do this in bus_acquired_handler since you are guaranteed that this will run before name is requested from the bus." (https://developer.gnome.org/gio/stable/gio-Owning-Bus-Names.html#g-bus-own-name) Unfortunately I can't reproduce it reliably according the downstream bugreport. However you can force the race by adding sleep, e.g.: diff --git a/daemon/mount.c b/daemon/mount.c index 9d8fb00..81f1dc4 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -1017,0 +1018,2 @@ mount_init (void) + sleep (5); Attaching patch to do exactly what documentation says... Downstream bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1039987
I forget to mention steps, how to reproduce... 1/ build gvfs with additional sleep 2/ dbus-launch gvfs-mount http://example.com
Review of attachment 295674 [details] [review]: Looks good!
Created attachment 295705 [details] [review] 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.
I think all the other uses are OK.
Review of attachment 295705 [details] [review]: Thanks for the patch, I missed this case. Looks good, you should just unref the connection and the main loop... ::: metadata/meta-daemon.c @@ +539,3 @@ + g_printerr ("Error exporting metadata daemon: %s (%s, %d)\n", + error->message, g_quark_to_string (error->domain), error->code); + g_error_free (error); g_object_unref (conn); g_main_loop_unref (loop);
Thanks for the review. Pushed with some error handling to master and gnome-3-14.
Comment on attachment 295674 [details] [review] register mount tracker skeleton by bus_acquired_handler Thanks for the review! Pushed to master and gnome-3-14: commit 871113ca3e534522e9ed5e48c424b7160221514c commit 07356a7f3e08e35033b76dcc34de74bcfa27465f