summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-04-18 08:54:33 +0200
committerThomas Haller <thaller@redhat.com>2021-04-19 07:35:27 +0200
commit29215185b640e47e01bdae3958597a4bda1d89cd (patch)
tree3cdf0cd21ce56fdf0748bfa3c6f550794a204c83
parentb63f7ec70b8da7306617f0c7089ae2a770472d1b (diff)
downloadglib-29215185b640e47e01bdae3958597a4bda1d89cd.tar.gz
gdbus: document completion after idle action for g_dbus_connection_signal_unsubscribe()
Since commit ab285899a6fb ('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] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/a55c10c6cb0cd047ff2aa835535d2abe09507ad6/src/libnm-client-impl/nm-client.c#L7918
-rw-r--r--gio/gdbusconnection.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index 28c6795bc..7c20462eb 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -3715,6 +3715,9 @@ unsubscribe_id_internal (GDBusConnection *connection,
* g_dbus_connection_signal_subscribe() is called, in order to avoid memory
* leaks through callbacks queued on the #GMainContext after it’s stopped being
* 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
*/