win32: wrap socket close() with an exception handler
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 15 May 2023 13:24:40 +0000 (17:24 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Sun, 28 May 2023 09:08:25 +0000 (13:08 +0400)
commitd89f30b4df13dfe389a4d6cf8a30b2f87c4c166e
tree7b4e7d66884f18a1da42936e9beece03b21f242f
parent0b31e48d62c8f3a282d1bffbcc0e90200df9f9f0
win32: wrap socket close() with an exception handler

Since commit abe34282 ("win32: avoid mixing SOCKET and file descriptor
space"), we set HANDLE_FLAG_PROTECT_FROM_CLOSE on the socket FD, to
prevent closing the HANDLE with CloseHandle. This raises an exception
which under gdb is fatal, and qemu exits.

Let's catch the expected error instead.

Note: this appears to work, but the mingw64 macro is not well documented
or tested, and it's not obvious how it is meant to be used.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230515132440.1025315-1-marcandre.lureau@redhat.com>
include/sysemu/os-win32.h
util/oslib-win32.c