diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-04-19 07:44:48 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-04-19 07:44:48 +0200 |
commit | e92030239abb4038d4f915d47021d6c037239309 (patch) | |
tree | 1c8c4877f35df78b7441a5736d8551b9b4877231 /support | |
parent | 62f71aad7e0d9df95578846134f1738ddf0e7844 (diff) | |
download | glibc-e92030239abb4038d4f915d47021d6c037239309.tar.gz glibc-e92030239abb4038d4f915d47021d6c037239309.tar.xz glibc-e92030239abb4038d4f915d47021d6c037239309.zip |
Assume that accept4 is always available and works
Simplify the Linux accept4 implementation based on the assumption that it is available in some way. __ASSUME_ACCEPT4_SOCKETCALL was previously unused, so remove it. For ia64, the accept4 system call (and socket call) were backported in kernel version 3.2.18. Reflect this in the installation instructions.
Diffstat (limited to 'support')
-rw-r--r-- | support/Makefile | 1 | ||||
-rw-r--r-- | support/xaccept4.c | 32 | ||||
-rw-r--r-- | support/xsocket.h | 1 |
3 files changed, 34 insertions, 0 deletions
diff --git a/support/Makefile b/support/Makefile index 1f33fa0c74..38dbd832e9 100644 --- a/support/Makefile +++ b/support/Makefile @@ -50,6 +50,7 @@ libsupport-routines = \ temp_file \ write_message \ xaccept \ + xaccept4 \ xasprintf \ xbind \ xcalloc \ diff --git a/support/xaccept4.c b/support/xaccept4.c new file mode 100644 index 0000000000..67dd95e9fb --- /dev/null +++ b/support/xaccept4.c @@ -0,0 +1,32 @@ +/* accept4 with error checking. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <support/xsocket.h> + +#include <stdio.h> +#include <stdlib.h> +#include <support/check.h> + +int +xaccept4 (int fd, struct sockaddr *sa, socklen_t *salen, int flags) +{ + int clientfd = accept4 (fd, sa, salen, flags); + if (clientfd < 0) + FAIL_EXIT1 ("accept4 (%d, 0x%x): %m", fd, flags); + return clientfd; +} diff --git a/support/xsocket.h b/support/xsocket.h index 0dbf13ace9..d6724948d8 100644 --- a/support/xsocket.h +++ b/support/xsocket.h @@ -30,6 +30,7 @@ void xconnect (int, const struct sockaddr *, socklen_t); void xbind (int, const struct sockaddr *, socklen_t); void xlisten (int, int); int xaccept (int, struct sockaddr *, socklen_t *); +int xaccept4 (int, struct sockaddr *, socklen_t *, int); void xsendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t); size_t xrecvfrom (int, void *, size_t, int, struct sockaddr *, socklen_t *); |