aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2023-02-21 16:48:01 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2023-03-13 15:39:31 +0400
commit25657fc6c1b693096e2ceadaa53cd10c1e81c8d9 (patch)
tree02de623f13a1d265022ddbdbf7433eb33f929d23 /net
parentb7e5374637daffa49657be2c559a0566836a172f (diff)
win32: replace closesocket() with close() wrapper
Use a close() wrapper instead, so that we don't need to worry about closesocket() vs close() anymore, let's hope. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Message-Id: <20230221124802.4103554-17-marcandre.lureau@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/dgram.c14
-rw-r--r--net/socket.c22
2 files changed, 18 insertions, 18 deletions
diff --git a/net/dgram.c b/net/dgram.c
index 9f7bf38376..48f653bceb 100644
--- a/net/dgram.c
+++ b/net/dgram.c
@@ -230,7 +230,7 @@ static int net_dgram_mcast_create(struct sockaddr_in *mcastaddr,
return fd;
fail:
if (fd >= 0) {
- closesocket(fd);
+ close(fd);
}
return -1;
}
@@ -352,7 +352,7 @@ static int net_dgram_mcast_init(NetClientState *peer,
if (convert_host_port(saddr, local->u.inet.host, local->u.inet.port,
errp) < 0) {
g_free(saddr);
- closesocket(fd);
+ close(fd);
return -1;
}
@@ -360,14 +360,14 @@ static int net_dgram_mcast_init(NetClientState *peer,
if (saddr->sin_addr.s_addr == 0) {
error_setg(errp, "can't setup multicast destination address");
g_free(saddr);
- closesocket(fd);
+ close(fd);
return -1;
}
/* clone dgram socket */
newfd = net_dgram_mcast_create(saddr, NULL, errp);
if (newfd < 0) {
g_free(saddr);
- closesocket(fd);
+ close(fd);
return -1;
}
/* clone newfd to fd, close newfd */
@@ -494,14 +494,14 @@ int net_init_dgram(const Netdev *netdev, const char *name,
if (ret < 0) {
error_setg_errno(errp, errno,
"can't set socket option SO_REUSEADDR");
- closesocket(fd);
+ close(fd);
return -1;
}
ret = bind(fd, (struct sockaddr *)&laddr_in, sizeof(laddr_in));
if (ret < 0) {
error_setg_errno(errp, errno, "can't bind ip=%s to socket",
inet_ntoa(laddr_in.sin_addr));
- closesocket(fd);
+ close(fd);
return -1;
}
qemu_socket_set_nonblock(fd);
@@ -548,7 +548,7 @@ int net_init_dgram(const Netdev *netdev, const char *name,
if (ret < 0) {
error_setg_errno(errp, errno, "can't bind unix=%s to socket",
laddr_un.sun_path);
- closesocket(fd);
+ close(fd);
return -1;
}
qemu_socket_set_nonblock(fd);
diff --git a/net/socket.c b/net/socket.c
index 2fc5696755..ba6e5b0b00 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -172,7 +172,7 @@ static void net_socket_send(void *opaque)
if (s->listen_fd != -1) {
qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s);
}
- closesocket(s->fd);
+ close(s->fd);
s->fd = -1;
net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
@@ -299,7 +299,7 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr,
return fd;
fail:
if (fd >= 0)
- closesocket(fd);
+ close(fd);
return -1;
}
@@ -314,7 +314,7 @@ static void net_socket_cleanup(NetClientState *nc)
}
if (s->listen_fd != -1) {
qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL);
- closesocket(s->listen_fd);
+ close(s->listen_fd);
s->listen_fd = -1;
}
}
@@ -399,7 +399,7 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
return s;
err:
- closesocket(fd);
+ close(fd);
return NULL;
}
@@ -456,7 +456,7 @@ static NetSocketState *net_socket_fd_init(NetClientState *peer,
if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type,
(socklen_t *)&optlen)< 0) {
error_setg(errp, "can't get socket option SO_TYPE");
- closesocket(fd);
+ close(fd);
return NULL;
}
switch(so_type) {
@@ -468,7 +468,7 @@ static NetSocketState *net_socket_fd_init(NetClientState *peer,
default:
error_setg(errp, "socket type=%d for fd=%d must be either"
" SOCK_DGRAM or SOCK_STREAM", so_type, fd);
- closesocket(fd);
+ close(fd);
}
return NULL;
}
@@ -526,13 +526,13 @@ static int net_socket_listen_init(NetClientState *peer,
if (ret < 0) {
error_setg_errno(errp, errno, "can't bind ip=%s to socket",
inet_ntoa(saddr.sin_addr));
- closesocket(fd);
+ close(fd);
return -1;
}
ret = listen(fd, 0);
if (ret < 0) {
error_setg_errno(errp, errno, "can't listen on socket");
- closesocket(fd);
+ close(fd);
return -1;
}
@@ -579,7 +579,7 @@ static int net_socket_connect_init(NetClientState *peer,
break;
} else {
error_setg_errno(errp, errno, "can't connect socket");
- closesocket(fd);
+ close(fd);
return -1;
}
} else {
@@ -671,14 +671,14 @@ static int net_socket_udp_init(NetClientState *peer,
if (ret < 0) {
error_setg_errno(errp, errno,
"can't set socket option SO_REUSEADDR");
- closesocket(fd);
+ close(fd);
return -1;
}
ret = bind(fd, (struct sockaddr *)&laddr, sizeof(laddr));
if (ret < 0) {
error_setg_errno(errp, errno, "can't bind ip=%s to socket",
inet_ntoa(laddr.sin_addr));
- closesocket(fd);
+ close(fd);
return -1;
}
qemu_socket_set_nonblock(fd);