moonbridge

diff moonbridge.c @ 214:45a425c75643

Use accept() only on Linux and only if _GNU_SOURCE is not set
author jbe
date Mon Jun 22 22:36:18 2015 +0200 (2015-06-22)
parents 43a077f2ab49
children 0b6555732047
line diff
     1.1 --- a/moonbridge.c	Mon Jun 22 22:26:55 2015 +0200
     1.2 +++ b/moonbridge.c	Mon Jun 22 22:36:18 2015 +0200
     1.3 @@ -1435,8 +1435,7 @@
     1.4    } else {
     1.5      int peerfd;
     1.6      do {
     1.7 -      /* peerfd = accept4(listener->listenfd, NULL, NULL, SOCK_CLOEXEC); */
     1.8 -      /* use accept() instead of accept4() to avoid _GNU_SOURCE on GNU/Linux */
     1.9 +#if defined(__linux__) && !defined(_GNU_SOURCE)
    1.10        peerfd = accept(listener->listenfd, NULL, NULL);
    1.11        if (peerfd != -1) {
    1.12          if (fcntl(peerfd, F_SETFD, FD_CLOEXEC) == -1) {
    1.13 @@ -1444,6 +1443,9 @@
    1.14            moonbr_terminate_error();
    1.15          }
    1.16        }
    1.17 +#else
    1.18 +      peerfd = accept4(listener->listenfd, NULL, NULL, SOCK_CLOEXEC);
    1.19 +#endif
    1.20        if (peerfd == -1) {
    1.21          if (errno == EWOULDBLOCK) {
    1.22            break;

Impressum / About Us