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 637220 - g_bus_own_name() triggers cancelled callbacks
g_bus_own_name() triggers cancelled callbacks
Status: RESOLVED DUPLICATE of bug 662808
Product: glib
Classification: Platform
Component: gdbus
unspecified
Other Linux
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-12-14 12:24 UTC by Mikkel Kamstrup Erlandsen
Modified: 2017-12-13 13:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Check if Client has been cancelled before invoking callbacks (1.19 KB, patch)
2010-12-14 12:24 UTC, Mikkel Kamstrup Erlandsen
none Details | Review

Description Mikkel Kamstrup Erlandsen 2010-12-14 12:24:01 UTC
Created attachment 176399 [details] [review]
Check if Client has been cancelled before invoking callbacks

If one does g_bus_own_name() followed by g_bus_unown_name() then the registered callbacks will still be called.

Attaching a patch fixing the issue.
Comment 1 David Zeuthen (not reading bugmail) 2010-12-16 20:26:38 UTC
Hmm, not sure this actually is a bug - the docs already state that things happen asynchronously. And since you might be using a GMainContext that will trigger callbacks in another thread, the patch will really do nothing since we might already have issued the callback before you get a chance to call g_bus_unown_name().

In fact we guarantee that one of the handlers will definitely be called. This patch would change that to "sometimes" even for the g_bus_own_name() followed by g_bus_unown_name().
Comment 2 Mikkel Kamstrup Erlandsen 2010-12-17 12:54:15 UTC
> Hmm, not sure this actually is a bug - the docs already state that things
> happen asynchronously. And since you might be using a GMainContext that will
> trigger callbacks in another thread, the patch will really do nothing since we
> might already have issued the callback before you get a chance to call
> g_bus_unown_name().

So it's in effect an async operation that can not be cancelled. Or at least not cancelled in a way that you can cleanly detect when you get the callback.

My case in point is that I have a GObject o that starts owning a name once created, and will drop the name once finalized/disposed, and I want to make it possible for consumers to do:

 o = my_object_new();
 g_object_unref (o);

and then rest assured that o is dead and gone past that point. I can use some weak-ref magic to make it work of course, but then things start getting more complicated than I had hoped for.

Are you open to other ways of detecting if an "owner id" has been cancelled?
Comment 3 Simon McVittie 2011-11-16 17:58:30 UTC
Is this the same as Bug #662808? (which looks pretty similar, but with more locking in the final commit)
Comment 4 Philip Withnall 2017-12-13 13:47:57 UTC
(In reply to Simon McVittie from comment #3)
> Is this the same as Bug #662808? (which looks pretty similar, but with more
> locking in the final commit)

It does look the same.

*** This bug has been marked as a duplicate of bug 662808 ***