qemu/io
Marc-André Lureau abe34282b0 win32: avoid mixing SOCKET and file descriptor space
Until now, a win32 SOCKET handle is often cast to an int file
descriptor, as this is what other OS use for sockets. When necessary,
QEMU eventually queries whether it's a socket with the help of
fd_is_socket(). However, there is no guarantee of conflict between the
fd and SOCKET space. Such conflict would have surprising consequences,
we shouldn't mix them.

Also, it is often forgotten that SOCKET must be closed with
closesocket(), and not close().

Instead, let's make the win32 socket wrapper functions return and take a
file descriptor, and let util/ wrappers do the fd/SOCKET conversion as
necessary. A bit of adaptation is necessary in io/ as well.

Unfortunately, we can't drop closesocket() usage, despite
_open_osfhandle() documentation claiming transfer of ownership, testing
shows bad behaviour if you forget to call closesocket().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-Id: <20230221124802.4103554-15-marcandre.lureau@redhat.com>
2023-03-13 15:39:31 +04:00
..
channel-buffer.c io: Add support for MSG_PEEK for socket channel 2023-02-06 19:22:56 +01:00
channel-command.c io: Add support for MSG_PEEK for socket channel 2023-02-06 19:22:56 +01:00
channel-file.c io: Add support for MSG_PEEK for socket channel 2023-02-06 19:22:56 +01:00
channel-null.c io: Add support for MSG_PEEK for socket channel 2023-02-06 19:22:56 +01:00
channel-socket.c win32/socket: introduce qemu_socket_unselect() helper 2023-03-13 15:23:37 +04:00
channel-tls.c io/channel-tls: fix handling of bigger read buffers 2023-02-15 11:01:04 -05:00
channel-util.c io: Fix Lesser GPL version number 2020-10-29 09:57:37 +00:00
channel-watch.c win32: avoid mixing SOCKET and file descriptor space 2023-03-13 15:39:31 +04:00
channel-websock.c io: Add support for MSG_PEEK for socket channel 2023-02-06 19:22:56 +01:00
channel.c io: Add support for MSG_PEEK for socket channel 2023-02-06 19:22:56 +01:00
dns-resolver.c build-sys: add HAVE_IPPROTO_MPTCP 2021-09-30 15:30:25 +02:00
meson.build io: add a QIOChannelNull equivalent to /dev/null 2022-06-22 18:11:21 +01:00
net-listener.c io/net-listener: Call the notifier during finalize 2021-06-08 19:36:17 +01:00
task.c io: Fix Lesser GPL version number 2020-10-29 09:57:37 +00:00
trace-events io: add a QIOChannelNull equivalent to /dev/null 2022-06-22 18:11:21 +01:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00