summaryrefslogtreecommitdiff
path: root/support/xaccept4.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-04-14 10:30:01 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-04-14 10:30:01 +0200
commit02191c903188162a48f57a4644dcd74809011151 (patch)
treeab9febb90f4428882d42c0ac334cf805662feca7 /support/xaccept4.c
parent6417a03b98b851c7e5fea01ffd744d497971277e (diff)
downloadglibc-fw/accept4.tar.gz
Assume that accept4 is always available and worksfw/accept4
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. Its functionality is implied by the complex #if condition in accept4.c.
Diffstat (limited to 'support/xaccept4.c')
-rw-r--r--support/xaccept4.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/support/xaccept4.c b/support/xaccept4.c
new file mode 100644
index 0000000000..b676b58ed6
--- /dev/null
+++ b/support/xaccept4.c
@@ -0,0 +1,32 @@
+/* accept with error checking.
+ Copyright (C) 2016-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;
+}