Proper determination of D-Bus name ownership
Submitted by Mario Rugiero
Assigned to Xfce Bug Triage
Description
This is against git master from a few weeks ago. If it doesn't apply I'll rebase it, but right now I'm copying directly from a different report as is. The explanation is also more or less copied.
Take the following situation.
- For some reason we have the well-known name owned by someone, but this someone doesn't answer connections.
- We have timeouts, making startup slow.
- After the timeouts, we try to take ownership of the name, which is probably reasonable.
The way appfinder works now, the following happens:
- We make a mistake. We use g_dbus_own_name and take its return value as meaningful proof that we're now the owner, when it always returns non-zero and is asynchronous. We have no idea if we own the name until after we run gtk_main_loop.
- We think we own the name, and thus are the server, so we must not die on close.
This happened in the context of issue #15623.
The attached patch takes care of it by using an explicit message to synchronously ask for ownership and detect whether it was granted. This way, if a server is running but doesn't answer, the new process realizes it isn't the server itself, so it must die when the window is closed, thus avoiding lingering processes.
This is the original patch, as attached to #15623: https://bugzilla.xfce.org/attachment.cgi?id=8733
I'm not sure if downloading and reattaching is mandatory, but of course will do if asked so. It just seemed more practical this way.
Version: Unspecified