Unix FD Passing

Thiago Macieira thiago at kde.org
Wed May 20 14:34:23 PDT 2009


Havoc Pennington wrote:
>Hi,
>
>On Wed, May 20, 2009 at 4:39 PM, Lennart Poettering <mzqohf at 0pointer.de> 
wrote:
>> I am not sure I fully understood your question, but I think generic
>> demarshalling code like that wouldn't make sense anyway. Because in
>> contrast to other fixed data types unix fds are special: you need to
>> close() them after use.
>
>Hmm, I think such code does exist now though (I think the Qt bindings do
> it?)

More or less. Right now, the demarshaller code will just ignore types it 
doesn't know and print a warning. However, there's also a 
"transmarshaller" code that copies from one DBusMessage into another and I 
think that's the one you're referring to.

It's basically a loop around a DBusMessageIter until it returns false: if 
the element is a basic type, it uses dbus_message_iter_get_basic and 
dbus_message_iter_append_basic. If the element is an array and its type is 
of fixed size, it uses dbus_message_iter_get_fixed_array and 
dbus_message_iter_append_fixed_array. Otherwise, it enters the element and 
recurses.

With the introduction of FD passing, this code will probably start leaking 
fds.

>I'm wondering a bit if the user of libdbus should have to enable
>feature extensions ... that would get pretty gross in the long term.
>But the problem is that if libdbus supports fds, but the binding
>doesn't, then in effect we don't support fds - but we're advertising
>that we do.

I'd say that's wise.

But to make matters simpler, I'd say that you can only choose features to 
enable at levels: the first one is to enable fd passing. If we add a new 
optional feature in the future, you can choose to enable none, fd passing 
only, or both features. The rationale here is that, if the binding has 
been updated to support the newer feature, the binding author should be 
aware of the earlier features too.

>We need to at least document that get_fixed_array will fail on fd
> arrays.

Just make it a non-fixed array.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freedesktop.org/archives/dbus/attachments/20090520/72f2b009/attachment.pgp 


More information about the dbus mailing list