On Tue, Oct 10, 2017 at 12:18:26PM -0500, Eric Blake wrote:
> 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 <[email protected]>
> > ---
> > 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.
You've already noticed the code in later patch which passes a smaller
size. This lets me avoid having to duplicate the iovec array and
set smaller iov_len
>
> > - 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.
Opps. Yeah, we need to cope with niov > 0 to satisfy qio_channel_writev
API contract, but the VNC server only ever sends a single iov element
so I didn't hit the bug.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|