aboutsummaryrefslogtreecommitdiff
path: root/net/dgram.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dgram.c')
-rw-r--r--net/dgram.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/net/dgram.c b/net/dgram.c
index 48f653b..baa126d 100644
--- a/net/dgram.c
+++ b/net/dgram.c
@@ -226,7 +226,10 @@ static int net_dgram_mcast_create(struct sockaddr_in *mcastaddr,
}
}
- qemu_socket_set_nonblock(fd);
+ if (!qemu_set_blocking(fd, false, errp)) {
+ goto fail;
+ }
+
return fd;
fail:
if (fd >= 0) {
@@ -284,7 +287,7 @@ static int net_dgram_mcast_init(NetClientState *peer,
Error **errp)
{
NetDgramState *s;
- int fd, ret;
+ int fd;
struct sockaddr_in *saddr;
if (remote->type != SOCKET_ADDRESS_TYPE_INET) {
@@ -332,11 +335,8 @@ static int net_dgram_mcast_init(NetClientState *peer,
g_free(saddr);
return -1;
}
- ret = qemu_socket_try_set_nonblock(fd);
- if (ret < 0) {
+ if (!qemu_set_blocking(fd, false, errp)) {
g_free(saddr);
- error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
- name, fd);
return -1;
}
@@ -504,7 +504,11 @@ int net_init_dgram(const Netdev *netdev, const char *name,
close(fd);
return -1;
}
- qemu_socket_set_nonblock(fd);
+
+ if (!qemu_set_blocking(fd, false, errp)) {
+ close(fd);
+ return -1;
+ }
dest_len = sizeof(raddr_in);
dest_addr = g_malloc(dest_len);
@@ -551,7 +555,10 @@ int net_init_dgram(const Netdev *netdev, const char *name,
close(fd);
return -1;
}
- qemu_socket_set_nonblock(fd);
+ if (!qemu_set_blocking(fd, false, errp)) {
+ close(fd);
+ return -1;
+ }
dest_len = sizeof(raddr_un);
dest_addr = g_malloc(dest_len);
@@ -562,10 +569,7 @@ int net_init_dgram(const Netdev *netdev, const char *name,
if (fd == -1) {
return -1;
}
- ret = qemu_socket_try_set_nonblock(fd);
- if (ret < 0) {
- error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
- name, fd);
+ if (!qemu_set_blocking(fd, false, errp)) {
return -1;
}
dest_addr = NULL;