[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/5] util/qemu-sockets: Replace the call to close a socket with c
From: |
Bin Meng |
Subject: |
[PATCH 1/5] util/qemu-sockets: Replace the call to close a socket with closesocket() |
Date: |
Wed, 27 Jul 2022 15:35:38 +0800 |
From: Bin Meng <bin.meng@windriver.com>
close() is a *nix function. It works on any file descriptor, and
sockets in *nix are an example of a file descriptor.
closesocket() is a Windows-specific function, which works only
specifically with sockets. Sockets on Windows do not use *nix-style
file descriptors, and socket() returns a handle to a kernel object
instead, so it must be closed with closesocket().
In QEMU there is already a logic to handle such platform difference
in os-posix.h and os-win32.h, that:
* closesocket maps to close on POSIX
* closesocket maps to a wrapper that calls the real closesocket()
on Windows
Replace the call to close a socket with closesocket() instead.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---
util/qemu-sockets.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 13b5b197f9..0e2298278f 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -487,7 +487,7 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error
**errp)
if (ret < 0) {
error_setg_errno(errp, errno, "Unable to set KEEPALIVE");
- close(sock);
+ closesocket(sock);
return -1;
}
}
@@ -1050,7 +1050,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr,
Error **errp)
return sock;
err:
- close(sock);
+ closesocket(sock);
return -1;
}
--
2.34.1
- [PATCH 0/5] Enable unix socket support on Windows, Bin Meng, 2022/07/27
- [PATCH 1/5] util/qemu-sockets: Replace the call to close a socket with closesocket(),
Bin Meng <=
- [PATCH 2/5] util/oslib-win32: Add a helper to get the Windows version, Bin Meng, 2022/07/27
- Re: [PATCH 2/5] util/oslib-win32: Add a helper to get the Windows version, Yan Vugenfirer, 2022/07/27
- Re: [PATCH 2/5] util/oslib-win32: Add a helper to get the Windows version, Bin Meng, 2022/07/27
- Re: [PATCH 2/5] util/oslib-win32: Add a helper to get the Windows version, Daniel P . Berrangé, 2022/07/27
- Re: [PATCH 2/5] util/oslib-win32: Add a helper to get the Windows version, Yan Vugenfirer, 2022/07/27
- Re: [PATCH 2/5] util/oslib-win32: Add a helper to get the Windows version, Bin Meng, 2022/07/27
- Re: [PATCH 2/5] util/oslib-win32: Add a helper to get the Windows version, Daniel P . Berrangé, 2022/07/27
- Re: [PATCH 2/5] util/oslib-win32: Add a helper to get the Windows version, Bin Meng, 2022/07/27
- Re: [PATCH 2/5] util/oslib-win32: Add a helper to get the Windows version, Konstantin Kostiuk, 2022/07/27
- Re: [PATCH 2/5] util/oslib-win32: Add a helper to get the Windows version, Bin Meng, 2022/07/27