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

login
register
mail settings
Submitter Juan Quintela
Date Dec. 19, 2012, 12:33 p.m.
Message ID <1355920437-29882-3-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/207331/
State New
Headers show

Comments

Juan Quintela - Dec. 19, 2012, 12:33 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>
---
 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;