[v2,4/4] buffered_file: do not automatically unfreeze output on buffered_put_buffer

Submitted by Paolo Bonzini on Nov. 20, 2012, 4:45 p.m.

Details

Message ID 1353429936-29180-5-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Nov. 20, 2012, 4:45 p.m.
Only unfreeze if the call comes from migrate_fd_put_notify.
If the output if frozen we can still add to the buffer (which
will not grow in an unbounded manner anyway, both with and
without the previous patch), but we will not try to flush until the
socket becomes writable.

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

Patch hide | download patch | download mbox

diff --git a/buffered_file.c b/buffered_file.c
index 2dac99a..862aa8d 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -109,14 +109,18 @@  static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in
         return error;
     }
 
-    DPRINTF("unfreezing output\n");
-    s->freeze_output = 0;
-
     if (size > 0) {
         DPRINTF("buffering %d bytes\n", size - offset);
         buffered_append(s, buf, size);
     }
 
+    if (pos == 0 && size == 0) {
+        DPRINTF("unfreezing output\n");
+        s->freeze_output = 0;
+    } else if (s->freeze_output) {
+        return size;
+    }
+
     error = buffered_flush(s);
     if (error < 0) {
         DPRINTF("buffered flush error. bailing: %s\n", strerror(-error));