mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
net: EAGAIN handling for net/socket.c UDP
Implement asynchronous send for UDP (or other SOCK_DGRAM) sockets. If send fails with EAGAIN we wait for the socket to become writable again. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
This commit is contained in:
parent
863f678fba
commit
213fd5087e
1 changed files with 12 additions and 2 deletions
14
net/socket.c
14
net/socket.c
|
@ -102,9 +102,19 @@ static ssize_t net_socket_receive(NetClientState *nc, const uint8_t *buf, size_t
|
||||||
static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf, size_t size)
|
static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf, size_t size)
|
||||||
{
|
{
|
||||||
NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc);
|
NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc);
|
||||||
|
ssize_t ret;
|
||||||
|
|
||||||
return sendto(s->fd, (const void *)buf, size, 0,
|
do {
|
||||||
(struct sockaddr *)&s->dgram_dst, sizeof(s->dgram_dst));
|
ret = sendto(s->fd, buf, size, 0,
|
||||||
|
(struct sockaddr *)&s->dgram_dst,
|
||||||
|
sizeof(s->dgram_dst));
|
||||||
|
} while (ret == -1 && errno == EINTR);
|
||||||
|
|
||||||
|
if (ret == -1 && errno == EAGAIN) {
|
||||||
|
net_socket_write_poll(s, true);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void net_socket_send(void *opaque)
|
static void net_socket_send(void *opaque)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue