Patchwork [57/60] buffered_file: do not send more than s->bytes_xfer bytes per tick

login
register
mail settings
Submitter Michael Tokarev
Date Feb. 4, 2013, 10:41 a.m.
Message ID <1359974470-17044-58-git-send-email-mjt@msgid.tls.msk.ru>
Download mbox | patch
Permalink /patch/217854/
State New
Headers show

Comments

Michael Tokarev - Feb. 4, 2013, 10:41 a.m.
From: Paolo Bonzini <pbonzini@redhat.com>

Sending more was possible if the buffer was large.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
(cherry picked from commit bde54c08b4854aceee3dee25121a2b835cb81166)

Conflicts (backport):
	buffered_file.c

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 buffered_file.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch

diff --git a/buffered_file.c b/buffered_file.c
index f170aa0..daf3cf4 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -85,9 +85,10 @@  static void buffered_flush(QEMUFileBuffered *s)
 
     while (offset < s->buffer_size) {
         ssize_t ret;
+        size_t to_send = MIN(s->buffer_size - offset, s->xfer_limit - s->bytes_xfer);
 
         ret = s->put_buffer(s->opaque, s->buffer + offset,
-                            s->buffer_size - offset);
+                            to_send);
         if (ret == -EAGAIN) {
             DPRINTF("backend not ready, freezing\n");
             s->freeze_output = 1;