win32: add qemu_close_socket_osfhandle()

Close the given file descriptor, but returns the underlying SOCKET.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20230320133643.1618437-2-marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2023-03-20 17:36:41 +04:00
parent aa9e7fa468
commit f3ab43accf
2 changed files with 53 additions and 37 deletions

View file

@ -171,10 +171,21 @@ bool qemu_socket_select(int sockfd, WSAEVENT hEventObject,
bool qemu_socket_unselect(int sockfd, Error **errp);
/* We wrap all the sockets functions so that we can
* set errno based on WSAGetLastError()
/* We wrap all the sockets functions so that we can set errno based on
* WSAGetLastError(), and use file-descriptors instead of SOCKET.
*/
/*
* qemu_close_socket_osfhandle:
* @fd: a file descriptor associated with a SOCKET
*
* Close only the C run-time file descriptor, leave the SOCKET opened.
*
* Returns zero on success. On error, -1 is returned, and errno is set to
* indicate the error.
*/
int qemu_close_socket_osfhandle(int fd);
#undef close
#define close qemu_close_wrap
int qemu_close_wrap(int fd);