diff mbox

[RFC,10/14] qemu-char: block during sync read

Message ID 1465076003-26291-11-git-send-email-marcandre.lureau@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marc-André Lureau June 4, 2016, 9:33 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

A sync read should block until data is available, instead of
retrying. Change the channel to blocking during read.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qemu-char.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox

Patch

diff --git a/qemu-char.c b/qemu-char.c
index efa1e2a..ce09226 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2911,7 +2911,9 @@  static int tcp_chr_sync_read(CharDriverState *chr, const uint8_t *buf, int len)
         return 0;
     }
 
+    qio_channel_set_blocking(s->ioc, true, NULL);
     size = tcp_chr_recv(chr, (void *) buf, len);
+    qio_channel_set_blocking(s->ioc, false, NULL);
     if (size == 0) {
         /* connection closed */
         tcp_chr_disconnect(chr);