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

login
register
mail settings
Submitter Michael Roth
Date Jan. 16, 2013, 4:49 p.m.
Message ID <1358354963-9070-17-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/212955/
State New
Headers show

Comments

Michael Roth - Jan. 16, 2013, 4:49 p.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)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 buffered_file.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/buffered_file.c b/buffered_file.c
index bd0f61d..9a8bd04 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -66,9 +66,9 @@  static ssize_t buffered_flush(QEMUFileBuffered *s)
     DPRINTF("flushing %zu byte(s) of data\n", s->buffer_size);
 
     while (s->bytes_xfer < s->xfer_limit && offset < s->buffer_size) {
-
+        size_t to_send = MIN(s->buffer_size - offset, s->xfer_limit - s->bytes_xfer);
         ret = migrate_fd_put_buffer(s->migration_state, s->buffer + offset,
-                                    s->buffer_size - offset);
+                                    to_send);
         if (ret == -EAGAIN) {
             DPRINTF("backend not ready, freezing\n");
             ret = 0;