Skip to content

Commit 2b6c068

Browse files
committed
Fix accept4 portability: define SOCK_NONBLOCK and SOCK_CLOEXEC
On non-Linux systems, SOCK_NONBLOCK and SOCK_CLOEXEC may not be defined. Add conditional defines for these constants in the portability wrapper.
1 parent 57fff48 commit 2b6c068

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/dns_server_tcp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010

1111
// Portability wrapper for accept4
1212
#ifndef __linux__
13+
// Define constants if not available on non-Linux systems
14+
#ifndef SOCK_NONBLOCK
15+
#define SOCK_NONBLOCK 0x800
16+
#endif
17+
#ifndef SOCK_CLOEXEC
18+
#define SOCK_CLOEXEC 0x80000
19+
#endif
20+
1321
// On non-Linux systems, implement accept4 using accept + fcntl
1422
static int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) {
1523
int fd = accept(sockfd, addr, addrlen);

0 commit comments

Comments
 (0)