[Spice-devel] [PATCH spice-common RFC] Fix linearization of several marshallers with one item

Javier Celaya javier.celaya at flexvdi.com
Mon Jul 27 04:33:32 PDT 2015


El Lunes, 27 de julio de 2015 13:27:14 Javier Celaya escribió:
> The linearization optimization that avoids copying only one item must
> check that there are no further marshallers in the chain.
> ---
>  common/marshaller.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/marshaller.c b/common/marshaller.c
> index bd012d7..0c6680e 100644
> --- a/common/marshaller.c
> +++ b/common/marshaller.c
> @@ -419,7 +419,7 @@ uint8_t *spice_marshaller_linearize(SpiceMarshaller *m,
> size_t skip_bytes, /* Only supported for root marshaller */
>      assert(m->data->marshallers == m);
> 
> -    if (m->n_items == 1) {
> +    if (m->n_items == 1 && m->next == NULL) {
>          *free_res = FALSE;
>          if (m->items[0].len <= skip_bytes) {
>              *len = 0;

Just to be clear, we are trying to marshall a message like this:

message {
    uint32 data_size;
    uint64 *data[data_size] @marshall;
} SomeData;

Where the data field points to an array in dynamic memory. Marshalling and 
demarshalling functions look good. The marshalling function creates a submarshaller 
for the data field and links it to the root marshaller. But when it comes to sending the 
data through the wire, only the data_size field gets sent. We have observed that, in 
spice_marshaller_linearize, execution enters into the optimization that avoids copying 
the data when the root marshaller only has one item, but it ignores the following 
marshallers in the list. Checking if there are more marshallers seems to fix the 
problem. What do you think?

Regards-- 


[1] [2]
*Javier Celaya *
/Software Engineer /
[3] j[4]_avier.celaya at flexvdi.com_ 
[5] +34 976 512 433 
[6] @j_celaya 


--------
[1] http://www.flexvdi.com/img/general/logo.flexvdi.png
[2] http://flexvdi.com
[3] http://flexvdi.com/signature/mail.png
[4] mailto:javier.celaya at flexvdi.com
[5] http://flexvdi.com/signature/phone.png
[6] http://flexvdi.com/signature/skype.png
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150727/bc35ad12/attachment.html>


More information about the Spice-devel mailing list