Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tcf-dev] Issue with TCF Streams Service

Hi Didier,

 

“size” is unencoded data size. I have changed service specs to resolve the ambiguity.

 

Regards,

Eugene

 

 

From: tcf-dev-bounces@xxxxxxxxxxx [mailto:tcf-dev-bounces@xxxxxxxxxxx] On Behalf Of Brachet, Didier
Sent: Wednesday, March 16, 2016 7:02 AM
To: tcf-dev@xxxxxxxxxxx
Subject: [tcf-dev] Issue with TCF Streams Service

 

Hello,

We have been facing an issue with the TCF Streams service and I am wondering if it is either an error in the documentation documentation or an error in the implementation of the service in the "C" agent.

In the TCF Streams documentation, we can see:

C • <token> • Streams • write • <string: stream ID><int: size><string: data>
  • stream ID

ID of stream that will receive the data.

  • size

Number of bytes to write. Length of data must match the size.

  • data

BASE64 encoded bytes that will be written to the stream.

In case your client does not support ZeroCopy and thus sends BASE64 encoded data; I understand that size represents the size of the data buffer when it is encoded encoded (which is twice the size of the binary buffer). I have two issues with this:

1 - When you want to write a TCF streams proxy; it is usually not possible to get the size of the encoded data after the data has been sent (after you have done the json_write_binary_start/json_write_binary_data/json_write_binary_end sequence) and this is too late. It would mean you have to first encode the data in a buffer and then send this data; this is not very handy.

2 - If we do really need to transfer the size of the BASE64 encoded data; then there is a bug in streamsservice.c, int virtual_stream_write() function.

The code:

    if (data != NULL) {
        WriteRequest * r = (WriteRequest *)loc_alloc_zero(sizeof(WriteRequest));        list_init(&r->link_client);
        r->client = client;
        r->data = "">         r->size = size - offs;
        strlcpy(r->token, token, sizeof(r->token));
        list_add_last(&r->link_client, &client->write_requests);
    }

should be replaced with:

    if (data != NULL) {
        WriteRequest * r = (WriteRequest *)loc_alloc_zero(sizeof(WriteRequest));        list_init(&r->link_client);
        r->client = client;
        r->data = "">         r->size = data_pos;
        strlcpy(r->token, token, sizeof(r->token));
        list_add_last(&r->link_client, &client->write_requests);
    }

Note that we must also move the definition of data_pos to do this.

If we don't do this, the size we return (r->size) is too big (it represents the size of the BASE64 encoded data instead of the size of the buffer we have read).

Is the TCF documentation correct or should we replace "Length of data must match the size." with something like "size must represent the size of the binary version of data buffer."?
In any case, I think we should do the fix in streamsservice.c since it will work in all cases.

Thanks,
Didier


-- 
Didier Brachet, Principal Technologist, Wind River
direct (33) 297.427.286 fax (33) 297.424.550


This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.


Back to the top