From 97d586a403b911c2d3e1c6a6a69313f0ab833509 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 1 May 2022 14:23:31 +0000 Subject: [PATCH] [ win64 ] fix socket blocking --- src/osdep/osdep.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/osdep/osdep.c b/src/osdep/osdep.c index f18f98919..0cc9cadb3 100644 --- a/src/osdep/osdep.c +++ b/src/osdep/osdep.c @@ -78,12 +78,12 @@ int set_nonblocking_fd(int fd) { #ifdef WIN32 - /* on current mingw (202204) - * this is correct usage of winsock - * when compiling for win32 */ - u_long mode = 1; // set non-blocking socket - return ioctlsocket(fd, FIONBIO, &mode); -# else + if (fd > 1024) { + u_long mode = 1; // set socket non-blocking + ioctlsocket(fd, FIONBIO, &mode); + return 0; + } +# endif #if defined(O_NONBLOCK) || defined(O_NDELAY) int flags = fcntl(fd, F_GETFL, 0); @@ -101,8 +101,6 @@ set_nonblocking_fd(int fd) #else return 0; #endif - -#endif } /* Set a file descriptor to blocking mode. It returns a non-zero value on @@ -111,12 +109,12 @@ int set_blocking_fd(int fd) { #ifdef WIN32 - /* on current mingw (202204) - * this is correct usage of winsock - * when compiling for win32 */ - u_long mode = 0; // set blocking socket - return ioctlsocket(fd, FIONBIO, &mode); -# else + if (fd > 1024) { + u_long mode = 0; // set socket blocking + ioctlsocket(fd, FIONBIO, &mode); + return 0; + } +# endif #if defined(O_NONBLOCK) || defined(O_NDELAY) int flags = fcntl(fd, F_GETFL, 0); @@ -134,7 +132,6 @@ set_blocking_fd(int fd) #else return 0; #endif -#endif } void