From patchwork Tue Nov 20 16:45:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v2, 4/4] buffered_file: do not automatically unfreeze output on buffered_put_buffer Date: Tue, 20 Nov 2012 06:45:36 -0000 From: Paolo Bonzini X-Patchwork-Id: 200402 Message-Id: <1353429936-29180-5-git-send-email-pbonzini@redhat.com> To: qemu-devel@nongnu.org Cc: quintela@redhat.com 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 --- buffered_file.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) 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));