audio: fix socket opening on OSX

On OSX we need a second call to fcntl to specify O_NON_BLOCK.
It's ignored when passed in socket()

Refs #69052

Change-Id: I7f9c356423d4d0c35a4dc04deb38b39ad1e0d576
This commit is contained in:
Alexandre Lision
2015-03-23 15:36:09 -04:00
parent e3a8bba344
commit 8eb6937323

View File

@ -55,7 +55,6 @@ extern "C" {
#ifdef __APPLE__
#include <fcntl.h>
#define SOCK_NONBLOCK O_NONBLOCK
#endif
namespace ring {
@ -153,10 +152,17 @@ udp_socket_create(sockaddr_storage *addr, socklen_t *addr_len, int local_port)
if (res0 == 0)
return -1;
for (res = res0; res; res=res->ai_next) {
#ifdef __APPLE__
udp_fd = socket(res->ai_family, SOCK_DGRAM, 0);
if (udp_fd != -1 && fcntl(udp_fd, F_SETFL, O_NONBLOCK) != -1) {
#else
udp_fd = socket(res->ai_family, SOCK_DGRAM | SOCK_NONBLOCK, 0);
if (udp_fd != -1) break;
if (udp_fd != -1) {
#endif
break;
}
RING_ERR("socket error");
}
}
if (udp_fd < 0) {
freeaddrinfo(res0);