Patchwork [v2,2/4] buffered_file: do not send more than s->bytes_xfer bytes per tick

login
register
mail settings
Submitter Paolo Bonzini
Date Nov. 20, 2012, 4:45 p.m.
Message ID <1353429936-29180-3-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/200401/
State New
Headers show

Comments

Paolo Bonzini - Nov. 20, 2012, 4:45 p.m.
Sending more was possible if the buffer was large.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 buffered_file.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/buffered_file.c b/buffered_file.c
index 49e9089..edead5c 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;