[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/10] chardev/char-fe: don't allow EAGAIN from blocking read
From: |
Roman Kagan |
Subject: |
[PATCH 04/10] chardev/char-fe: don't allow EAGAIN from blocking read |
Date: |
Thu, 11 Nov 2021 18:33:48 +0300 |
As its name suggests, ChardevClass.chr_sync_read is supposed to do a
blocking read. The only implementation of it, tcp_chr_sync_read, does
set the underlying io channel to the blocking mode indeed.
Therefore a failure return with EAGAIN is not expected from this call.
So do not retry it in qemu_chr_fe_read_all; instead place an assertion
that it doesn't fail with EAGAIN.
Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
---
chardev/char-fe.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index 7789f7be9c..f94efe928e 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -68,13 +68,10 @@ int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int
len)
}
while (offset < len) {
- retry:
res = CHARDEV_GET_CLASS(s)->chr_sync_read(s, buf + offset,
len - offset);
- if (res == -1 && errno == EAGAIN) {
- g_usleep(100);
- goto retry;
- }
+ /* ->chr_sync_read should block */
+ assert(!(res < 0 && errno == EAGAIN));
if (res == 0) {
break;
--
2.33.1
- Re: [PATCH 05/10] vhost-backend: avoid overflow on memslots_limit, (continued)
[PATCH 07/10] vhost-vdpa: stick to -errno error return convention, Roman Kagan, 2021/11/11
[PATCH 02/10] chardev/char-socket: tcp_chr_recv: don't clobber errno, Roman Kagan, 2021/11/11
[PATCH 09/10] vhost: stick to -errno error return convention, Roman Kagan, 2021/11/11
[PATCH 10/10] vhost-user-blk: propagate error return from generic vhost, Roman Kagan, 2021/11/11
[PATCH 08/10] vhost-user: stick to -errno error return convention, Roman Kagan, 2021/11/11
[PATCH 04/10] chardev/char-fe: don't allow EAGAIN from blocking read,
Roman Kagan <=
Re: [PATCH 00/10] vhost: stick to -errno error return convention, Michael S. Tsirkin, 2021/11/11
Re: [PATCH 00/10] vhost: stick to -errno error return convention, Michael S. Tsirkin, 2021/11/28