moonbridge
changeset 212:453b7d1a7944
Avoid use of accept4() function in favor of accept() to avoid using _GNU_SOURCE on GNU/Linux
author | jbe |
---|---|
date | Mon Jun 22 22:19:41 2015 +0200 (2015-06-22) |
parents | a3d569d3e85d |
children | 43a077f2ab49 |
files | moonbridge.c moonbridge_io.c |
line diff
1.1 --- a/moonbridge.c Mon Jun 22 21:26:33 2015 +0200 1.2 +++ b/moonbridge.c Mon Jun 22 22:19:41 2015 +0200 1.3 @@ -17,9 +17,6 @@ 1.4 1.5 /*** Include directives for used system libraries ***/ 1.6 1.7 -#if defined(__linux__) 1.8 -#define _GNU_SOURCE 1.9 -#endif 1.10 #include <stdlib.h> 1.11 #include <stdint.h> 1.12 #include <string.h> 1.13 @@ -1435,7 +1432,15 @@ 1.14 } else { 1.15 int peerfd; 1.16 do { 1.17 - peerfd = accept4(listener->listenfd, NULL, NULL, SOCK_CLOEXEC); 1.18 + /* peerfd = accept4(listener->listenfd, NULL, NULL, SOCK_CLOEXEC); */ 1.19 + /* use accept() instead of accept4() to avoid _GNU_SOURCE on GNU/Linux */ 1.20 + peerfd = accept(listener->listenfd, NULL, NULL); 1.21 + if (peerfd != -1) { 1.22 + if (fcntl(peerfd, F_SETFD, FD_CLOEXEC) == -1) { 1.23 + moonbr_log(LOG_ERR, "Error in fcntl() call: %s", strerror(errno)); 1.24 + moonbr_terminate_error(); 1.25 + } 1.26 + } 1.27 if (peerfd == -1) { 1.28 if (errno == EWOULDBLOCK) { 1.29 break;
2.1 --- a/moonbridge_io.c Mon Jun 22 21:26:33 2015 +0200 2.2 +++ b/moonbridge_io.c Mon Jun 22 22:19:41 2015 +0200 2.3 @@ -3,9 +3,6 @@ 2.4 #define __has_include(x) 0 2.5 #endif 2.6 2.7 -#if defined(__linux__) 2.8 -#define _GNU_SOURCE 2.9 -#endif 2.10 #include <stdlib.h> 2.11 #include <stdint.h> 2.12 #include <string.h>