[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v1 5/7] io: get rid of bounce buffering in webso
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v1 5/7] io: get rid of bounce buffering in websock write path |
Date: |
Tue, 10 Oct 2017 12:29:16 -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:
> Currently most outbound I/O on the websock channel gets copied into the
> rawoutput buffer, and then immediately copied again into the encoutput
> buffer, with a header prepended. Now that qio_channel_websock_encode
> accepts a struct iovec, we can trivially remove this bounce buffering
> and write directly to encoutput.
>
> In doing so, we also now correctly validate the encoutput size against
> the QIO_CHANNEL_WEBSOCK_MAX_BUFFER limit.
>
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
> include/io/channel-websock.h | 1 -
> io/channel-websock.c | 64
> +++++++++++++++++++-------------------------
> 2 files changed, 28 insertions(+), 37 deletions(-)
>
> - iov.iov_base = ioc->rawoutput.buffer;
> - iov.iov_len = ioc->rawoutput.offset;
> qio_channel_websock_encode(ioc, QIO_CHANNEL_WEBSOCK_OPCODE_CLOSE,
> - &iov, 1, iov.iov_len);
> - buffer_reset(&ioc->rawoutput);
> + iov, niov, size);
If 4/7 changes this to compute size from the iov/niov, then this has
knock-on impact.
> @@ -1115,32 +1118,21 @@ static ssize_t qio_channel_websock_writev(QIOChannel
> *ioc,
> return -1;
> + avail = wioc->encoutput.offset >= QIO_CHANNEL_WEBSOCK_MAX_BUFFER ?
> + 0 : (QIO_CHANNEL_WEBSOCK_MAX_BUFFER - wioc->encoutput.offset);
> + if (want > avail) {
> + want = avail;
> }
>
> - done:
> - if (wioc->rawoutput.offset) {
> - struct iovec iov = { .iov_base = wioc->rawoutput.buffer,
> - .iov_len = wioc->rawoutput.offset };
> + if (want) {
> qio_channel_websock_encode(wioc,
> QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME,
> - &iov, 1, iov.iov_len);
> - buffer_reset(&wioc->rawoutput);
> + iov, niov, want);
then again, I see that you DO support want < iov_size(iov, niov).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v1 0/7] Limit websockets memory usage & other bug fixes, Daniel P. Berrange, 2017/10/10
- [Qemu-devel] [PATCH v1 2/7] io: simplify websocket ping reply handling, Daniel P. Berrange, 2017/10/10
- [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
- Re: [Qemu-devel] [PATCH v1 5/7] io: get rid of bounce buffering in websock write path,
Eric Blake <=
- [Qemu-devel] [PATCH v1 4/7] io: pass a struct iovec into qio_channel_websock_encode, Daniel P. Berrange, 2017/10/10
- [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