summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mq_notify.c29
-rw-r--r--sysdeps/unix/sysv/linux/opensock.c39
3 files changed, 16 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index cafcb4de9e..0e7c7e9b60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2014-06-20  Joseph Myers  <joseph@codesourcery.com>
+
+	* nptl/sysdeps/unix/sysv/linux/mq_notify.c: Do not include
+	<kernel-features.h>.
+	(init_mq_netlink): Remove conditional have_sock_cloexec
+	definitions.  Remove code conditional on have_sock_cloexec < 0.
+	(init_mq_netlink) [!SOCK_CLOEXEC]: Remove conditional code.
+	(init_mq_netlink) [!__ASSUME_SOCK_CLOEXEC]: Likewise.
+	* sysdeps/unix/sysv/linux/opensock.c: Do not include
+	<kernel-features.h>.
+	(__opensock) [SOCK_CLOEXEC]: Make code unconditional.
+	(__opensock) [!__ASSUME_SOCK_CLOEXEC]: Remove conditional code.
+
 2014-06-20  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* sysdeps/x86_64/multiarch/ifunc-impl-list.c (__libc_ifunc_impl_list):
diff --git a/nptl/sysdeps/unix/sysv/linux/mq_notify.c b/nptl/sysdeps/unix/sysv/linux/mq_notify.c
index 3138ad2c3c..6893d8ced8 100644
--- a/nptl/sysdeps/unix/sysv/linux/mq_notify.c
+++ b/nptl/sysdeps/unix/sysv/linux/mq_notify.c
@@ -28,7 +28,6 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <not-cancel.h>
-#include <kernel-features.h>
 #include <nptl/pthreadP.h>
 
 
@@ -153,41 +152,15 @@ reset_once (void)
 static void
 init_mq_netlink (void)
 {
-#ifdef SOCK_CLOEXEC
-# ifndef __ASSUME_SOCK_CLOEXEC
-  static int have_sock_cloexec;
-# else
-#  define have_sock_cloexec 1
-# endif
-#else
-# define have_sock_cloexec -1
-# define SOCK_CLOEXEC 0
-#endif
-
   /* This code might be called a second time after fork().  The file
      descriptor is inherited from the parent.  */
   if (netlink_socket == -1)
     {
       /* Just a normal netlink socket, not bound.  */
-      if (have_sock_cloexec >= 0)
-	{
-	  netlink_socket = socket (AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, 0);
-#if defined SOCK_CLOEXEC && !defined __ASSUME_SOCK_CLOEXEC
-	  if (have_sock_cloexec == 0)
-	    have_sock_cloexec = (netlink_socket != -1 || errno != EINVAL
-				 ? 1 : -1);
-#endif
-	}
-      if (have_sock_cloexec < 0)
-	netlink_socket = socket (AF_NETLINK, SOCK_RAW, 0);
+      netlink_socket = socket (AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, 0);
       /* No need to do more if we have no socket.  */
       if (netlink_socket == -1)
 	return;
-
-      /* Make sure the descriptor is closed on exec.  */
-      if (have_sock_cloexec < 0
-	  && fcntl (netlink_socket, F_SETFD, FD_CLOEXEC) != 0)
-	goto errout;
     }
 
   int err = 1;
diff --git a/sysdeps/unix/sysv/linux/opensock.c b/sysdeps/unix/sysv/linux/opensock.c
index bcf7f5fc40..4894bf995f 100644
--- a/sysdeps/unix/sysv/linux/opensock.c
+++ b/sysdeps/unix/sysv/linux/opensock.c
@@ -21,7 +21,6 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/socket.h>
-#include <kernel-features.h>
 
 /* Return a socket of any type.  The socket can be used in subsequent
    ioctl calls to talk to the kernel.  */
@@ -63,24 +62,7 @@ __opensock (void)
     {
       assert (last_type != 0);
 
-#ifdef SOCK_CLOEXEC
-# ifndef __ASSUME_SOCK_CLOEXEC
-      if (__have_sock_cloexec >= 0)
-# endif
-	{
-	  result = __socket (last_family, last_type | SOCK_CLOEXEC, 0);
-# ifndef __ASSUME_SOCK_CLOEXEC
-	  if (__have_sock_cloexec == 0)
-	    __have_sock_cloexec = result != -1 || errno != EINVAL ? 1 : -1;
-# endif
-	}
-#endif
-#ifndef __ASSUME_SOCK_CLOEXEC
-# ifdef SOCK_CLOEXEC
-      if (__have_sock_cloexec < 0)
-# endif
-	result = __socket (last_family, last_type, 0);
-#endif
+      result = __socket (last_family, last_type | SOCK_CLOEXEC, 0);
       if (result != -1 || errno != EAFNOSUPPORT)
 	/* Maybe the socket type isn't supported anymore (module is
 	   unloaded).  In this case again try to find the type.  */
@@ -115,24 +97,7 @@ __opensock (void)
       if (afs[cnt].family == AF_NETROM || afs[cnt].family == AF_X25)
 	type = SOCK_SEQPACKET;
 
-#ifdef SOCK_CLOEXEC
-# ifndef __ASSUME_SOCK_CLOEXEC
-      if (__have_sock_cloexec >= 0)
-# endif
-	{
-	  result = __socket (afs[cnt].family, type | SOCK_CLOEXEC, 0);
-# ifndef __ASSUME_SOCK_CLOEXEC
-	  if (__have_sock_cloexec == 0)
-	    __have_sock_cloexec = result != -1 || errno != EINVAL ? 1 : -1;
-# endif
-	}
-#endif
-#ifndef __ASSUME_SOCK_CLOEXEC
-# ifdef SOCK_CLOEXEC
-      if (__have_sock_cloexec < 0)
-# endif
-	result = __socket (afs[cnt].family, type, 0);
-#endif
+      result = __socket (afs[cnt].family, type | SOCK_CLOEXEC, 0);
       if (result != -1)
 	{
 	  /* Found an available family.  */