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

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