Commit 8eb69373 authored by Alexandre Lision's avatar Alexandre Lision

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
parent e3a8bba3
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment