From: Eric Blake <eblake@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 4/7] io: pass a struct iovec into qio_channel_websock_encode
Date: Wed, 11 Oct 2017 07:30:45 -0500 [thread overview]
Message-ID: <731291c2-90f9-e83a-73d7-ebe42da13d0c@redhat.com> (raw)
In-Reply-To: <20171011100959.29326-5-berrange@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1566 bytes --]
On 10/11/2017 05:09 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 <berrange@redhat.com>
> +static void qio_channel_websock_encode(QIOChannelWebsock *ioc,
> + uint8_t opcode,
> + const struct iovec *iov,
> + size_t niov,
> + size_t size)
> {
> size_t header_size;
> + size_t i;
> union {
> char buf[QIO_CHANNEL_WEBSOCK_HEADER_LEN_64_BIT];
> QIOChannelWebsockHeader ws;
Is it worth adding assert(size <= iov_size(iov, niov)) near the top,
> + 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[i].iov_len;
> + if (want > size) {
> + want = size;
> + }
> + buffer_append(&ioc->encoutput, iov[i].iov_base, want);
> + size -= want;
> + }
so we don't have to worry about a huge size causing us to buffer_reserve
far too much space?
Doesn't affect my R-b, though.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2017-10-11 12:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 10:09 [Qemu-devel] [PATCH v2 0/7] Limit websockets memory usage & other bug fixes Daniel P. Berrange
2017-10-11 10:09 ` [Qemu-devel] [PATCH v2 1/7] io: monitor encoutput buffer size from websocket GSource Daniel P. Berrange
2017-10-11 10:09 ` [Qemu-devel] [PATCH v2 2/7] io: simplify websocket ping reply handling Daniel P. Berrange
2017-10-11 10:09 ` [Qemu-devel] [PATCH v2 3/7] io: get rid of qio_channel_websock_encode helper method Daniel P. Berrange
2017-10-11 10:09 ` [Qemu-devel] [PATCH v2 4/7] io: pass a struct iovec into qio_channel_websock_encode Daniel P. Berrange
2017-10-11 12:28 ` Eric Blake
2017-10-11 12:30 ` Eric Blake [this message]
2017-10-11 12:31 ` Daniel P. Berrange
2017-10-11 10:09 ` [Qemu-devel] [PATCH v2 5/7] io: get rid of bounce buffering in websock write path Daniel P. Berrange
2017-10-11 12:58 ` Eric Blake
2017-10-11 10:09 ` [Qemu-devel] [PATCH v2 6/7] io: cope with websock 'Connection' header having multiple values Daniel P. Berrange
2017-10-11 10:09 ` [Qemu-devel] [PATCH v2 7/7] io: add trace points for websocket HTTP protocol headers Daniel P. Berrange
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=731291c2-90f9-e83a-73d7-ebe42da13d0c@redhat.com \
--to=eblake@redhat.com \
--cc=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).