Skip to content
Snippets Groups Projects
Commit 8eb69373 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

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
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,6 @@ extern "C" { ...@@ -55,7 +55,6 @@ extern "C" {
#ifdef __APPLE__ #ifdef __APPLE__
#include <fcntl.h> #include <fcntl.h>
#define SOCK_NONBLOCK O_NONBLOCK
#endif #endif
namespace ring { namespace ring {
...@@ -153,8 +152,15 @@ udp_socket_create(sockaddr_storage *addr, socklen_t *addr_len, int local_port) ...@@ -153,8 +152,15 @@ udp_socket_create(sockaddr_storage *addr, socklen_t *addr_len, int local_port)
if (res0 == 0) if (res0 == 0)
return -1; return -1;
for (res = res0; res; res=res->ai_next) { 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); 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"); RING_ERR("socket error");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment