diff options
author | Nikita Ivanov <nivanov@cloudlinux.com> | 2022-10-23 12:04:22 +0300 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2023-01-09 13:50:47 +0100 |
commit | 37b0b24e933c18269dddbf6b83f91823cacf8105 (patch) | |
tree | b36ac8d45a9e188604e44998974d27cf6185e0f3 /net/socket.c | |
parent | 8b6aa69365ca6e9bbc3bf557a6ccc5ed2b468bec (diff) |
error handling: Use RETRY_ON_EINTR() macro where applicable
There is a defined RETRY_ON_EINTR() macro in qemu/osdep.h
which handles the same while loop.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/415
Signed-off-by: Nikita Ivanov <nivanov@cloudlinux.com>
Message-Id: <20221023090422.242617-3-nivanov@cloudlinux.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[thuth: Dropped the hunk that changed socket_accept() in libqtest.c]
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/net/socket.c b/net/socket.c index b67437a1f0..2fc5696755 100644 --- a/net/socket.c +++ b/net/socket.c @@ -117,15 +117,13 @@ static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf, NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc); ssize_t ret; - do { - if (s->dgram_dst.sin_family != AF_UNIX) { - ret = sendto(s->fd, buf, size, 0, - (struct sockaddr *)&s->dgram_dst, - sizeof(s->dgram_dst)); - } else { - ret = send(s->fd, buf, size, 0); - } - } while (ret == -1 && errno == EINTR); + ret = RETRY_ON_EINTR( + s->dgram_dst.sin_family != AF_UNIX ? + sendto(s->fd, buf, size, 0, + (struct sockaddr *)&s->dgram_dst, + sizeof(s->dgram_dst)) : + send(s->fd, buf, size, 0) + ); if (ret == -1 && errno == EAGAIN) { net_socket_write_poll(s, true); |