GDBusConnection: when to close, when to unref

David Zeuthen zeuthen at gmail.com
Sat Jun 8 11:02:01 PDT 2013


Hi,

On Fri, Jun 7, 2013 at 3:30 AM, Simon McVittie
<simon.mcvittie at collabora.co.uk> wrote:
> Private connections are like file objects: it's best to
> close-then-unref. It is not an error to just do the unref, but that way
> you can't detect errors, and if you have leaked a ref somewhere, the
> connection will remain open.

Depending on your application, you may also want to flush [1] the
connection before closing and unreffing it. In the file analogy above,
this is similar to how you sometimes want to fsync(2) a file before
close(2)'ing it.

    David

[1] :
https://developer.gnome.org/gio/unstable/GDBusConnection.html#g-dbus-connection-flush
https://developer.gnome.org/gio/unstable/GDBusConnection.html#g-dbus-connection-close


More information about the dbus mailing list