gdbus: document completion after idle action for g_dbus_connection_signal_unsubscribe()

Since commit ab285899a6 ('gdbusconnection: Document main context
iteration for unsubscript'), we document when the user is guaranteed
that all resources are gone after g_dbus_connection_signal_unsubscribe().
This is not merely an implementation detail, it's something that the
user needs to be able to rely on. It is good that this is documented.

However, libnm does something different ([1]). It registers to several D-Bus
signals without providing a GDestroyNotify. After unsubscription, it schedules
another idle action with lower priority and uses that to know when
cleanup is complete. I think this is a useful alternative and should
also be guaranteed and documented to work.

Also note that this isn't just some implementation detail that currently
happens to work. GDBusConnection tightly integrates with GMainContext and it
works by scheduling idle sources with G_PRIORITY_DEFAULT priority. It needs to
schedule all events with this same priority, otherwise the ordering is not
preserved. At this point, with GDBusConnection working this way, this is no longer
something that can reasonably be any different. It's how GDBusConnection fundamentally
works, and a user must be able to rely on that. As such, this new promise isn't
something that we would want to break in the future.

Thus document it.

[1] a55c10c6cb/src/libnm-client-impl/nm-client.c (L7918)
This commit is contained in:
Thomas Haller 2021-04-18 08:54:33 +02:00
parent 66fe1da95a
commit b0157af9a6

View File

@ -3715,6 +3715,9 @@ unsubscribe_id_internal (GDBusConnection *connection,
* g_dbus_connection_signal_subscribe() is called, in order to avoid memory * g_dbus_connection_signal_subscribe() is called, in order to avoid memory
* leaks through callbacks queued on the #GMainContext after its stopped being * leaks through callbacks queued on the #GMainContext after its stopped being
* iterated. * iterated.
* Alternatively, any idle source with a priority lower than %G_PRIORITY_DEFAULT
* that was scheduled after unsubscription, also indicates that all resources
* of this subscription are released.
* *
* Since: 2.26 * Since: 2.26
*/ */