win32/socket: introduce qemu_socket_unselect() helper

A more explicit version of qemu_socket_select() with no events.

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

View file

@ -169,6 +169,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()
*/

View file

@ -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);

View file

@ -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)