win32/socket: introduce qemu_socket_select() helper

This is a wrapper for WSAEventSelect, with Error handling. By default,
it will produce a warning, so callers don't have to be modified
now, and yet we can spot potential mis-use.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20230221124802.4103554-7-marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2023-02-21 16:47:51 +04:00
parent 3ffef1a55c
commit f5fd677ae7
6 changed files with 30 additions and 10 deletions

View file

@ -442,7 +442,7 @@ static void qio_channel_socket_finalize(Object *obj)
}
}
#ifdef WIN32
WSAEventSelect(ioc->fd, NULL, 0);
qemu_socket_select(ioc->fd, NULL, 0, NULL);
#endif
closesocket(ioc->fd);
ioc->fd = -1;
@ -846,7 +846,7 @@ qio_channel_socket_close(QIOChannel *ioc,
if (sioc->fd != -1) {
#ifdef WIN32
WSAEventSelect(sioc->fd, NULL, 0);
qemu_socket_select(sioc->fd, NULL, 0, NULL);
#endif
if (qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_LISTEN)) {
socket_listen_cleanup(sioc->fd, errp);