[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 07/16] win32/socket: introduce qemu_socket_unselect() helper
From: |
marcandre . lureau |
Subject: |
[PATCH v3 07/16] win32/socket: introduce qemu_socket_unselect() helper |
Date: |
Tue, 21 Feb 2023 16:47:52 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
A more explicit version of qemu_socket_select() with no events.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/sysemu/os-win32.h | 2 ++
io/channel-socket.c | 4 ++--
util/oslib-win32.c | 7 ++++++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index 0afb79cc2e..ae0c9a3659 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -149,6 +149,8 @@ static inline void qemu_funlockfile(FILE *f)
bool qemu_socket_select(SOCKET s, WSAEVENT hEventObject,
long lNetworkEvents, Error **errp);
+bool qemu_socket_unselect(SOCKET s, Error **errp);
+
/* We wrap all the sockets functions so that we can
* set errno based on WSAGetLastError()
*/
diff --git a/io/channel-socket.c b/io/channel-socket.c
index 0bc29c4808..03757c7a7e 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -442,7 +442,7 @@ static void qio_channel_socket_finalize(Object *obj)
}
}
#ifdef WIN32
- qemu_socket_select(ioc->fd, NULL, 0, NULL);
+ qemu_socket_unselect(ioc->fd, NULL);
#endif
closesocket(ioc->fd);
ioc->fd = -1;
@@ -846,7 +846,7 @@ qio_channel_socket_close(QIOChannel *ioc,
if (sioc->fd != -1) {
#ifdef WIN32
- qemu_socket_select(sioc->fd, NULL, 0, NULL);
+ qemu_socket_unselect(sioc->fd, NULL);
#endif
if (qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_LISTEN)) {
socket_listen_cleanup(sioc->fd, errp);
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index df752fc762..dbd32acc98 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -180,7 +180,7 @@ static int socket_error(void)
void qemu_socket_set_block(int fd)
{
unsigned long opt = 0;
- qemu_socket_select(fd, NULL, 0, NULL);
+ qemu_socket_unselect(fd, NULL);
ioctlsocket(fd, FIONBIO, &opt);
}
@@ -298,6 +298,11 @@ bool qemu_socket_select(SOCKET s, WSAEVENT hEventObject,
return true;
}
+bool qemu_socket_unselect(SOCKET s, Error **errp)
+{
+ return qemu_socket_select(s, NULL, 0, errp);
+}
+
#undef connect
int qemu_connect_wrap(int sockfd, const struct sockaddr *addr,
socklen_t addrlen)
--
2.39.2
- [PATCH v3 00/16] win32: do not mix SOCKET and fd space, marcandre . lureau, 2023/02/21
- [PATCH v3 01/16] util: drop qemu_fork(), marcandre . lureau, 2023/02/21
- [PATCH v3 02/16] tests: use closesocket(), marcandre . lureau, 2023/02/21
- [PATCH v3 03/16] io: use closesocket(), marcandre . lureau, 2023/02/21
- [PATCH v3 04/16] tests: add test-error-report, marcandre . lureau, 2023/02/21
- [PATCH v3 05/16] error: add global &error_warn destination, marcandre . lureau, 2023/02/21
- [PATCH v3 06/16] win32/socket: introduce qemu_socket_select() helper, marcandre . lureau, 2023/02/21
- [PATCH v3 07/16] win32/socket: introduce qemu_socket_unselect() helper,
marcandre . lureau <=
- [PATCH v3 08/16] aio: make aio_set_fd_poll() static to aio-posix.c, marcandre . lureau, 2023/02/21
- [PATCH v3 10/16] RFC: build-sys: add slirp.wrap, marcandre . lureau, 2023/02/21
- [PATCH v3 09/16] aio/win32: aio_set_fd_handler() only supports SOCKET, marcandre . lureau, 2023/02/21
- [PATCH v3 13/16] slirp: open-code qemu_socket_(un)select(), marcandre . lureau, 2023/02/21
- [PATCH v3 12/16] slirp: unregister the win32 SOCKET, marcandre . lureau, 2023/02/21
- [PATCH v3 11/16] main-loop: remove qemu_fd_register(), win32/slirp/socket specific, marcandre . lureau, 2023/02/21
- [PATCH v3 14/16] win32: avoid mixing SOCKET and file descriptor space, marcandre . lureau, 2023/02/21
- [PATCH v3 15/16] os-posix: remove useless ioctlsocket() define, marcandre . lureau, 2023/02/21