[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v1 4/7] io: pass a struct iovec into qio_channel
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v1 4/7] io: pass a struct iovec into qio_channel_websock_encode |
Date: |
Tue, 10 Oct 2017 12:18:26 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 10/10/2017 10:43 AM, Daniel P. Berrange wrote:
> Instead of requiring use of another Buffer, pass a struct iovec
> into qio_channel_websock_encode, which gives callers more
> flexibility in how they process data.
>
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
> io/channel-websock.c | 69
> ++++++++++++++++++++++++++++++++--------------------
> 1 file changed, 42 insertions(+), 27 deletions(-)
>
> +static void qio_channel_websock_encode(QIOChannelWebsock *ioc,
> + uint8_t opcode,
> + const struct iovec *iov,
> + size_t niov,
> + size_t size)
> {
Is size redundant with iov_size(iov, niov)? Or is a caller allowed to
pass a smaller size (tail end of iov is not encoded) or larger size
(encoding stops at end of iov, even if size is not exhausted)? I'd lean
towards the former (one less parameter), especially since all callers in
this patch could have passed iov_size(&iov, 1) for the same effect.
> - trace_qio_channel_websock_encode(ioc, opcode, header_size,
> buffer->offset);
> - buffer_reserve(output, header_size + buffer->offset);
> - buffer_append(output, header.buf, header_size);
> - buffer_append(output, buffer->buffer, buffer->offset);
> + trace_qio_channel_websock_encode(ioc, opcode, header_size, size);
> + buffer_reserve(&ioc->encoutput, header_size + size);
> + buffer_append(&ioc->encoutput, header.buf, header_size);
> + for (i = 0; i < niov && size != 0; i++) {
> + size_t want = iov->iov_len;
> + if (want > size) {
> + want = size;
> + }
> + buffer_append(&ioc->encoutput, iov->iov_base, want);
> + size -= want;
> + }
Umm, where are you incrementing iov? It appears you only tested with
niov == 1.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v1 2/7] io: simplify websocket ping reply handling, (continued)
- [Qemu-devel] [PATCH v1 3/7] io: get rid of qio_channel_websock_encode helper method, Daniel P. Berrange, 2017/10/10
- [Qemu-devel] [PATCH v1 1/7] io: monitor encoutput buffer size from websocket GSource, Daniel P. Berrange, 2017/10/10
- [Qemu-devel] [PATCH v1 5/7] io: get rid of bounce buffering in websock write path, Daniel P. Berrange, 2017/10/10
- [Qemu-devel] [PATCH v1 4/7] io: pass a struct iovec into qio_channel_websock_encode, Daniel P. Berrange, 2017/10/10
- Re: [Qemu-devel] [PATCH v1 4/7] io: pass a struct iovec into qio_channel_websock_encode,
Eric Blake <=
- [Qemu-devel] [PATCH v1 7/7] io: add trace points for websocket HTTP protocol headers, Daniel P. Berrange, 2017/10/10
- [Qemu-devel] [PATCH v1 6/7] io: cope with websock 'Connection' header having multiple values, Daniel P. Berrange, 2017/10/10