summaryrefslogtreecommitdiffstats
path: root/drivers/unix
diff options
context:
space:
mode:
authorPablo Andres Fuente <pfuente@heroku.com>2024-09-16 23:38:32 -0300
committerRémi Verschelde <rverschelde@gmail.com>2024-09-17 16:09:33 +0200
commit84e24017b03ab2e4675281610e22f549e9991f79 (patch)
tree666ec89d52246a0a3eb3f6f564ff2cca9cda5c99 /drivers/unix
parent02b16d2f544e323b7b7f57e6e992b0b8e5d8b954 (diff)
downloadredot-engine-84e24017b03ab2e4675281610e22f549e9991f79.tar.gz
Adding a macro on NetSocketPosix to pick the right type for FIONREAD len
On Windows, `ioctlsocket` returns `len` as an unsigned long. On Posix, `ioctl` returns `len` as an int. This aims to fix #41287 bug, which was seen on Linux. The implementation is just a new macro that is set with the proper type for each platform.
Diffstat (limited to 'drivers/unix')
-rw-r--r--drivers/unix/net_socket_posix.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp
index 1e52b39be1..5caa33100e 100644
--- a/drivers/unix/net_socket_posix.cpp
+++ b/drivers/unix/net_socket_posix.cpp
@@ -67,6 +67,7 @@
#define SOCK_BUF(x) x
#define SOCK_CBUF(x) x
#define SOCK_IOCTL ioctl
+#define SOCK_FIONREAD_LEN_TYPE int
#define SOCK_CLOSE ::close
#define SOCK_CONNECT(p_sock, p_addr, p_addr_len) ::connect(p_sock, p_addr, p_addr_len)
@@ -81,6 +82,7 @@
#define SOCK_BUF(x) (char *)(x)
#define SOCK_CBUF(x) (const char *)(x)
#define SOCK_IOCTL ioctlsocket
+#define SOCK_FIONREAD_LEN_TYPE unsigned long
#define SOCK_CLOSE closesocket
// connect is broken on windows under certain conditions, reasons unknown:
// See https://github.com/godotengine/webrtc-native/issues/6
@@ -742,7 +744,7 @@ bool NetSocketPosix::is_open() const {
int NetSocketPosix::get_available_bytes() const {
ERR_FAIL_COND_V(!is_open(), -1);
- unsigned long len;
+ SOCK_FIONREAD_LEN_TYPE len;
int ret = SOCK_IOCTL(_sock, FIONREAD, &len);
if (ret == -1) {
_get_socket_error();