render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
6d3351
From 94c718948745cb7359002dbfd0e298203e574e02 Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <94c718948745cb7359002dbfd0e298203e574e02@dist-git>
6d3351
From: "Richard W.M. Jones" <rjones@redhat.com>
6d3351
Date: Fri, 26 May 2017 16:05:04 +0200
6d3351
Subject: [PATCH] rpc: Double buffer size instead of quadrupling buffer size.
6d3351
MIME-Version: 1.0
6d3351
Content-Type: text/plain; charset=UTF-8
6d3351
Content-Transfer-Encoding: 8bit
6d3351
6d3351
When increasing the buffer size up to VIR_NET_MESSAGE_MAX, we
6d3351
currently quadruple it each time.  This unfortunately means that we
6d3351
cannot allow certain buffer sizes -- for example the current
6d3351
VIR_NET_MESSAGE_MAX == 33554432 can never be "hit" since ‘newlen’
6d3351
jumps from 16MB to 64MB.
6d3351
6d3351
Instead of quadrupling, double it each time.
6d3351
6d3351
Thanks: Daniel Berrange.
6d3351
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
6d3351
(cherry picked from commit b088f85d42a05a6c0c8418c02a67b48864ba95a3)
6d3351
6d3351
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1440683
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 src/rpc/virnetmessage.c | 3 ++-
6d3351
 1 file changed, 2 insertions(+), 1 deletion(-)
6d3351
6d3351
diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
6d3351
index c3a2e595c..5908b074a 100644
6d3351
--- a/src/rpc/virnetmessage.c
6d3351
+++ b/src/rpc/virnetmessage.c
6d3351
@@ -358,7 +358,8 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
6d3351
 
6d3351
     /* Try to encode the payload. If the buffer is too small increase it. */
6d3351
     while (!(*filter)(&xdr, data, 0)) {
6d3351
-        unsigned int newlen = (msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX) * 4;
6d3351
+        unsigned int newlen = msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX;
6d3351
+        newlen *= 2;
6d3351
 
6d3351
         if (newlen > VIR_NET_MESSAGE_MAX) {
6d3351
             virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message payload"));
6d3351
-- 
6d3351
2.13.0
6d3351