Created attachment 3885 Patch: don't exit with failure if bus names are taken Hi! I've been having an issue with autostarting Tumbler as a D-Bus service, described in detail here: https://bugs.freedesktop.org/show_bug.cgi?id=41233 (basically, if a program tries to connect to eg. the .Cache and .Thumbnailer names at once, DBus launches two instances of tumblerd, the second one exits with an error because the bus names are taken, and so the calling program is given an error when in fact the .Thumbnailer interface is now available, just from a different interface) Here's a patch to return success instead of failure if the bus names are taken, which fixes the problem. I feel it's a bit of a hack, but I don't see what harm it could cause.
Fixed in master, see the commit details below. I'm not sure it is worth treating DBUS_REQUEST_NAME_REPLY_EXISTS special or if all possible results mean that the service is already running (they probably do). BTW, I didn't use TUMBLER_ERROR because that is more or less reserved for errors reported back to thumbnailer clients (or is used this way at least). The commit also registers the service GObjects first and then tries to acquire the D-Bus names, as suggested by Thiago on https://bugs.freedesktop.org/show_bug.cgi?id=41233. commit 776070012e3d5d2bff5a1b2a9e175ced7122f125 Author: Jannis Pohlmann <jannis@xfce.org> Date: Wed Sep 28 23:11:57 2011 +0200 Fix ownership race conditions when started twice (bug #8001). It can happen that D-Bus activates tumblerd multiple times if the activated instance doesn't bring up the service quickly enough. We need to detect this in order to exit duplicate instances gracefully (exit code 0). Exiting with an error code breaks clients. For more information, see the following bugs: https://bugzilla.xfce.org/show_bug.cgi?id=8001 https://bugs.freedesktop.org/show_bug.cgi?id=41233
Ok, simplified the fix in a second commit (now it's much closer to your solution as well): commit 72525b63d3fb581e1077c10e4b7be61a171ffd01 Author: Jannis Pohlmann <jannis@xfce.org> Date: Wed Sep 28 23:30:56 2011 +0200 Simplify the race fix. Failed name ownership implies already running. The only other results dbus_bus_request_name() returns are either not possible or imply that the service is already provided by another instance, so we don't have to treat DBUS_REQUEST_NAME_REPLY_EXISTS special.