DBusServer accepted client close

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Fri Oct 5 21:45:58 UTC 2018


On Fri, 5 Oct 2018 11:17:43 +0100, Simon McVittie wrote:

> That tells you when the connection has no more references. Sometimes
> that's what you want, but you do have to be careful not to create
> cyclic references that would keep the DBusConnection object in memory
> forever.

Yup, that’s the usual issue you have to watch for. The usual solution
is to use weak references somewhere in the cycle to break it. Or, in C
code, “borrowed” ones.

> Its primary use is to associate some state with a connection
> that will be freed eventually: for instance you might attach details
> of the client, like resources it has allocated in your server, to the
> connection so that you can easily deallocate them when it goes away.

I assumed that’s what the OP wanted.

> The other possible end point for a DBusConnection is when it has
> disconnected - the equivalent of read() or recv() returning 0 bytes
> (the end-of-file indicator) on a pipe or socket. libdbus guarantees
> that disconnection will be signalled by a special fake message being
> "received" by the connection, as though it had come from the client:

Thanks for that description. I have added the definition to DBussy:
<https://github.com/ldo/dbussy/commit/f674dd36dee4004db9522fede2175a744eac85d4>.


More information about the dbus mailing list