From: RĂ©mi Denis-Courmont Date: Sun, 8 Nov 2009 11:02:43 +0000 (+0200) Subject: Linux: use accept4 if available (glibc 2.10) X-Git-Tag: 1.1.0-ff~2556 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=3585accf1f4c128f46a9b86da9742c3260a7221a;p=vlc Linux: use accept4 if available (glibc 2.10) --- diff --git a/configure.ac b/configure.ac index 40b46c7fb9..423216841d 100644 --- a/configure.ac +++ b/configure.ac @@ -583,7 +583,7 @@ AC_CHECK_FUNCS(fdatasync,, ]) dnl Check for non-standard system calls -AC_CHECK_FUNCS([vmsplice eventfd fstatfs]) +AC_CHECK_FUNCS([vmsplice eventfd fstatfs accept4]) AH_BOTTOM([#include ]) diff --git a/src/network/httpd.c b/src/network/httpd.c index c01666155e..9103194929 100644 --- a/src/network/httpd.c +++ b/src/network/httpd.c @@ -2517,6 +2517,10 @@ static void* httpd_HostThread( void *data ) continue; /* */ +#ifdef HAVE_ACCEPT4 + fd = accept4 (fd, NULL, NULL, SOCK_CLOEXEC); + if (fd == -1 && errno == ENOSYS) +#endif fd = accept (fd, NULL, NULL); if (fd == -1) continue; diff --git a/src/network/tcp.c b/src/network/tcp.c index 4297a20a1e..0347010b2e 100644 --- a/src/network/tcp.c +++ b/src/network/tcp.c @@ -255,8 +255,15 @@ next_ai: /* failure */ int net_AcceptSingle (vlc_object_t *obj, int lfd) { int fd; + do + { +#ifdef HAVE_ACCEPT4 + fd = accept4 (lfd, NULL, NULL, SOCK_CLOEXEC); + if (fd == -1 && errno == ENOSYS) +#endif fd = accept (lfd, NULL, NULL); + } while (fd == -1 && errno == EINTR); if (fd == -1)