Re: [PATCH 02/15] Provide a simple object for encoding/decoding RPC messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/16/2010 04:21 AM, Daniel P. Berrange wrote:
> This provides a new struct that contains a buffer for the RPC
> message header+payload, as well as a decoded copy of the message
> header. There is an API for applying a XDR encoding & decoding
> of the message headers and payloads. There are also APIs for
> maintaining a simple FIFO queue of message instances.
> 

> +
> +/*
> + * @msg: the outgoing message, whose header to encode
> + *
> + * Encodes the length word and header of the  message, setting the

spacing: s/  / /

> +
> +int virNetMessageEncodePayload(virNetMessagePtr msg,
> +                               xdrproc_t filter,
> +                               void *data)
> +{
> +    XDR xdr;
> +    unsigned int msglen;
> +
> +    /* Serialise header followed by args. */

This comment is out of place, since the header should already have been
serialized prior to this function.

> +
> +
> +int virNetMessageDecodePayload(virNetMessagePtr msg,
> +                               xdrproc_t filter,
> +                               void *data)
> +{
> +    XDR xdr;
> +
> +    /* Serialise header followed by args. */

Likewise.

> +
> +int virNetMessageEncodePayloadRaw(virNetMessagePtr msg,
> +                                  const char *data,
> +                                  size_t len)
> +{
> +    XDR xdr;
> +    unsigned int msglen;
> +
> +    if ((msg->bufferLength - msg->bufferOffset) < len) {
> +        virNetError(VIR_ERR_RPC,
> +                    _("Stream data too long to send (%zu bytes needed, %zu bytes available)"),
> +                    len, (msg->bufferLength - msg->bufferOffset));
> +        return -1;
> +    }
> +
> +    memcpy(msg->buffer + msg->bufferOffset, data, len);
> +    msg->bufferOffset += len;

Should this round up to a multiple of 4, per the rules of XDR encoding?

But in general, this looks okay.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]