mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-13 16:03:23 -05:00
[misc] Define SOCK_NONBLOCK and SOCK_CLOEXEC if platform doesn't
This commit is contained in:
parent
64d6b0d4c3
commit
790c9dcca9
@ -205,11 +205,7 @@ net_connect(const char *addr, unsigned short port, int type, const char *log_ser
|
||||
|
||||
for (ptr = servinfo; ptr; ptr = ptr->ai_next)
|
||||
{
|
||||
#ifdef SOCK_CLOEXEC
|
||||
fd = socket(ptr->ai_family, type | SOCK_CLOEXEC, ptr->ai_protocol);
|
||||
#else
|
||||
fd = socket(ptr->ai_family, type, ptr->ai_protocol);
|
||||
#endif
|
||||
if (fd < 0)
|
||||
{
|
||||
continue;
|
||||
@ -273,11 +269,7 @@ net_bind(short unsigned *port, int type, const char *log_service_name)
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
|
||||
#ifdef SOCK_CLOEXEC
|
||||
fd = socket(ptr->ai_family, type | SOCK_CLOEXEC, ptr->ai_protocol);
|
||||
#else
|
||||
fd = socket(ptr->ai_family, type, ptr->ai_protocol);
|
||||
#endif
|
||||
if (fd < 0)
|
||||
continue;
|
||||
|
||||
|
@ -16,6 +16,15 @@
|
||||
#include <netinet/in.h>
|
||||
#include <event2/http.h>
|
||||
|
||||
#ifndef SOCK_NONBLOCK
|
||||
#include <fcntl.h>
|
||||
#define SOCK_NONBLOCK O_NONBLOCK
|
||||
#endif
|
||||
|
||||
#ifndef SOCK_CLOEXEC
|
||||
#define SOCK_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
union net_sockaddr
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
|
Loading…
Reference in New Issue
Block a user