fix: add enabled arg to setNonBlocking

This commit is contained in:
2026-05-13 11:28:07 -03:00
parent 88d3b3a32a
commit 5552d78562
+8 -3
View File
@@ -103,13 +103,18 @@ struct HttpStream
/* /*
platform specific stuff platform specific stuff
*/ */
void setNonBlocking(SOCKET s) void setNonBlocking(SOCKET s, bool enabled)
{ {
#ifdef _WIN32 #ifdef _WIN32
unsigned long mode = 1; unsigned long mode = enabled ? 1 : 0;
ioctlsocket(s, FIONBIO, &mode); ioctlsocket(s, FIONBIO, &mode);
#else #else
fcntl(s, F_SETFL, fcntl(s, F_GETFL, 0) | O_NONBLOCK); int flags = fcntl(s, F_GETFL, 0);
if (enabled)
flags |= O_NONBLOCK;
else
flags &= ~O_NONBLOCK;
fcntl(s, F_SETFL, flags);
#endif #endif
} }