After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 743653 - race condition when registering mount tracker skeleton
race condition when registering mount tracker skeleton
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: daemon
git master
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2015-01-28 15:58 UTC by Ondrej Holy
Modified: 2015-02-02 14:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
register mount tracker skeleton by bus_acquired_handler (1.92 KB, patch)
2015-01-28 15:58 UTC, Ondrej Holy
committed Details | Review
metadata: Export skeleton before name is acquired (3.28 KB, patch)
2015-01-28 23:11 UTC, Ross Lagerwall
committed Details | Review

Description Ondrej Holy 2015-01-28 15:58:38 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
Comment 1 Ondrej Holy 2015-01-28 16:10:55 UTC
I forget to mention steps, how to reproduce...

1/ build gvfs with additional sleep
2/ dbus-launch gvfs-mount http://example.com
Comment 2 Ross Lagerwall 2015-01-28 22:52:06 UTC
Review of attachment 295674 [details] [review]:

Looks good!
Comment 3 Ross Lagerwall 2015-01-28 23:11:04 UTC
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.
Comment 4 Ross Lagerwall 2015-01-28 23:15:47 UTC
I think all the other uses are OK.
Comment 5 Ondrej Holy 2015-01-29 09:19:48 UTC
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);
Comment 6 Ross Lagerwall 2015-01-31 10:29:02 UTC
Thanks for the review. Pushed with some error handling to master and gnome-3-14.
Comment 7 Ondrej Holy 2015-02-02 14:40:48 UTC
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