Skip to contentSkip to conversation

chardev: block during sync read

PATCH In review Marc-André Lureau 2 participants 2 messages Jul 6, 2017 – Jul 7, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 chardev: block during sync read

A sync read should block until all requested data is available (instead of retrying in qemu_chr_fe_read_all). Change the channel to blocking during sync_read.

---
 chardev/char-socket.c | 2 ++
 1 file changed, 2 insertions(+)
chardev/char-socket.c +2 -0
index ccc499cfa1..7e6648b03a 100644
@@ -454,7 +454,9 @@ static int tcp_chr_sync_read(Chardev *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);
Signature · 1 line
2.13.1.395.gf7b71de06
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Marc-André Lureau

A sync read should block until all requested data is available (instead of retrying in qemu_chr_fe_read_all). Change the channel to blocking during sync_read.

---
 chardev/char-socket.c | 2 ++
 1 file changed, 2 insertions(+)
chardev/char-socket.c +0 -0
index ccc499cfa1..7e6648b03a 100644

chardev/char-socket.c static int tcp_chr_sync_read(Chardev *chr, const uint8_t *buf, int len) · line 462

Quoted 9 lines
chardev/char-socket.c +2 -0
@@ -454,7 +454,9 @@ static int tcp_chr_sync_read(Chardev *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);