From db03761e16f945fdc639f88a0c316eeda665980b Mon Sep 17 00:00:00 2001 From: Umut Tezduyar Lindskog Date: Fri, 10 Jul 2015 14:31:53 +0200 Subject: [PATCH] man: sd_unref does not necessarily free the bus Document that sd_unref() does not necessarily free the bus, even if no part of the program explicitly refs it, due to the queued messages. --- man/sd_bus_default.xml | 6 ++++++ man/sd_bus_new.xml | 16 +++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/man/sd_bus_default.xml b/man/sd_bus_default.xml index 95b347bdfd..782dfb5706 100644 --- a/man/sd_bus_default.xml +++ b/man/sd_bus_default.xml @@ -219,6 +219,12 @@ one. Use sd_bus_unref3 to drop the reference. + + Queued messages also keep a reference to the bus. For this reason, just + because no application is having a reference to the bus does not mean that + the bus object will be destroyed. Until all the messages are sent, the bus object + will stay alive. sd_bus_flush can be used to send all the + queued messages so they drop their references. diff --git a/man/sd_bus_new.xml b/man/sd_bus_new.xml index 44744a0029..aff2ed2e83 100644 --- a/man/sd_bus_new.xml +++ b/man/sd_bus_new.xml @@ -77,8 +77,8 @@ sd_bus_new() creates a new bus object. This object is reference-counted, and will be destroyed when all references are gone. Initially, the caller of this - function owns the sole reference. The bus object will not be - connected to any bus initially. To connect it to a bus, make sure + function owns the sole reference and the bus object will not be + connected to any bus. To connect it to a bus, make sure to set an address with sd_bus_set_address3 or a related call, and then start the connection with @@ -94,15 +94,13 @@ well-known bus in a single function invocation. sd_bus_ref() creates a new reference to - bus. This bus object will not be destroyed - until sd_bus_unref() has been called as many - times plus once more. Once the reference count has dropped to - zero, bus cannot be used anymore, so - further calls to sd_bus_ref() or - sd_bus_unref() are illegal. + bus. sd_bus_unref() destroys a reference to - bus. + bus. Once the reference count has dropped + to zero, bus cannot be used anymore, so + further calls to sd_bus_ref() or + sd_bus_unref() are illegal.