Merge pull request #11583 from Alcaro/patch-11

Fix backwards condition in socket blocking behavior
This commit is contained in:
Autechre 2020-11-16 18:42:08 +01:00 committed by GitHub
commit 17333de0e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,11 +126,11 @@ int socket_receive_all_blocking(int fd, void *data_, size_t size)
bool socket_set_block(int fd, bool block) bool socket_set_block(int fd, bool block)
{ {
#if defined(__CELLOS_LV2__) || defined(VITA) || defined(WIIU) #if defined(__CELLOS_LV2__) || defined(VITA) || defined(WIIU)
int i = block; int i = !block;
setsockopt(fd, SOL_SOCKET, SO_NBIO, &i, sizeof(int)); setsockopt(fd, SOL_SOCKET, SO_NBIO, &i, sizeof(int));
return true; return true;
#elif defined(_WIN32) #elif defined(_WIN32)
u_long mode = block; u_long mode = !block;
return ioctlsocket(fd, FIONBIO, &mode) == 0; return ioctlsocket(fd, FIONBIO, &mode) == 0;
#else #else
return fcntl(fd, F_SETFL, (fcntl(fd, F_GETFL) & ~O_NONBLOCK) | (block ? 0 : O_NONBLOCK)) == 0; return fcntl(fd, F_SETFL, (fcntl(fd, F_GETFL) & ~O_NONBLOCK) | (block ? 0 : O_NONBLOCK)) == 0;