Blame SOURCES/kvm-io-get-rid-of-qio_channel_websock_encode-helper-meth.patch

4a2fec
From 87e23865f2383a8befcba2908dcd56c708a2fbb8 Mon Sep 17 00:00:00 2001
4a2fec
From: "Daniel P. Berrange" <berrange@redhat.com>
4a2fec
Date: Wed, 20 Dec 2017 17:56:56 +0100
4a2fec
Subject: [PATCH 16/42] io: get rid of qio_channel_websock_encode helper method
4a2fec
4a2fec
RH-Author: Daniel P. Berrange <berrange@redhat.com>
4a2fec
Message-id: <20171220175702.29663-15-berrange@redhat.com>
4a2fec
Patchwork-id: 78467
4a2fec
O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH v2 14/20] io: get rid of qio_channel_websock_encode helper method
4a2fec
Bugzilla: 1518649
4a2fec
RH-Acked-by: John Snow <jsnow@redhat.com>
4a2fec
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
4a2fec
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
The qio_channel_websock_encode method is only used in one place,
4a2fec
everything else calls qio_channel_websock_encode_buffer directly.
4a2fec
It can also be pushed up a level into the qio_channel_websock_writev
4a2fec
method, since every other caller of qio_channel_websock_write_wire
4a2fec
has already filled encoutput.
4a2fec
4a2fec
Reviewed-by: Eric Blake <eblake@redhat.com>
4a2fec
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
4a2fec
(cherry picked from commit bac6c95415788c03590542eb244c723a18d0771c)
4a2fec
4a2fec
NB, in qio_channel_websock_writev  s/ioc/wioc/ to fix a typo
4a2fec
upstream that would break builds during git bisect.
4a2fec
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 io/channel-websock.c | 20 ++++++--------------
4a2fec
 1 file changed, 6 insertions(+), 14 deletions(-)
4a2fec
4a2fec
diff --git a/io/channel-websock.c b/io/channel-websock.c
4a2fec
index 6083f74..403b72b 100644
4a2fec
--- a/io/channel-websock.c
4a2fec
+++ b/io/channel-websock.c
4a2fec
@@ -616,18 +616,6 @@ static void qio_channel_websock_encode_buffer(QIOChannelWebsock *ioc,
4a2fec
 }
4a2fec
 
4a2fec
 
4a2fec
-static void qio_channel_websock_encode(QIOChannelWebsock *ioc)
4a2fec
-{
4a2fec
-    if (!ioc->rawoutput.offset) {
4a2fec
-        return;
4a2fec
-    }
4a2fec
-    qio_channel_websock_encode_buffer(
4a2fec
-        ioc, &ioc->encoutput, QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME,
4a2fec
-        &ioc->rawoutput);
4a2fec
-    buffer_reset(&ioc->rawoutput);
4a2fec
-}
4a2fec
-
4a2fec
-
4a2fec
 static ssize_t qio_channel_websock_write_wire(QIOChannelWebsock *, Error **);
4a2fec
 
4a2fec
 
4a2fec
@@ -948,8 +936,6 @@ static ssize_t qio_channel_websock_write_wire(QIOChannelWebsock *ioc,
4a2fec
     ssize_t ret;
4a2fec
     ssize_t done = 0;
4a2fec
 
4a2fec
-    qio_channel_websock_encode(ioc);
4a2fec
-
4a2fec
     while (ioc->encoutput.offset > 0) {
4a2fec
         ret = qio_channel_write(ioc->master,
4a2fec
                                 (char *)ioc->encoutput.buffer,
4a2fec
@@ -1134,6 +1120,12 @@ static ssize_t qio_channel_websock_writev(QIOChannel *ioc,
4a2fec
     }
4a2fec
 
4a2fec
  done:
4a2fec
+    if (wioc->rawoutput.offset) {
4a2fec
+        qio_channel_websock_encode_buffer(
4a2fec
+            wioc, &wioc->encoutput, QIO_CHANNEL_WEBSOCK_OPCODE_BINARY_FRAME,
4a2fec
+            &wioc->rawoutput);
4a2fec
+        buffer_reset(&wioc->rawoutput);
4a2fec
+    }
4a2fec
     ret = qio_channel_websock_write_wire(wioc, errp);
4a2fec
     if (ret < 0 &&
4a2fec
         ret != QIO_CHANNEL_ERR_BLOCK) {
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec