render / rpms / libvirt

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