dbus_message_demarshal() and partial messages

Thiago Macieira thiago at kde.org
Tue Aug 14 17:27:28 PDT 2007


Avery Pennarun wrote:
>I might name it dbus_message_demarshal_bytes_needed().
>
>Note that in my imagination, if the provided length is less than
>DBUS_MINIMUM_HEADER_SIZE, then x should probably be
>DBUS_MINIMUM_HEADER_SIZE.  If you come back with that number of bytes,
>then you get a new, larger x.  This make it obvious how to write your
>socket library:
>
>x = dbus_message_demarshal_bytes_needed(buf, len);
>if (x > len)
>    read more bytes;
>else
>    dbus_message_demarshal();
>
>Any comments?  How do we go about getting such a function into the
> library?

I'd rather not return DBUS_MINIMUM_HEADER_SIZE because it could indicate 
that that's EXACTLY the number of bytes wanted when it clearly isn't.

But, seeing that that symbol is public, we can probably say that if you 
don't have DBUS_MINIMUM_HEADER_SIZE bytes available, you shouldn't be 
calling the bytes_needed function. So I'd return -1 and make that an 
error (probably one of those assertions "you're not using this function 
properly").

-- 
  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/20070815/735f121a/attachment.pgp 


More information about the dbus mailing list