GDBusConnection: when to close, when to unref

Lars Hanisch dvb at flensrocker.de
Sat Jun 8 23:58:18 PDT 2013


Hi,
Am 08.06.2013 20:02, schrieb David Zeuthen:
> 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.

 Thank you, that's exactly, what I'm doing. :)

 Before this I haven't done anything with GIO and its asynchronous pattern (but did some stuff with libdbus). For now I
call g_dbus_connection_flush and in its callback after the _flush_finish I call _close. Is this the right way or can I
call _flush and _close one after the other and will their callbacks be called in the right order?

Lars.

> 
>     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
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus
>


More information about the dbus mailing list