about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-07-25 17:06:50 +0000
committerUlrich Drepper <drepper@redhat.com>2008-07-25 17:06:50 +0000
commit8ccf22f93431a2f8c77de708cd3b15325c8fe0f4 (patch)
treeea971b1800c807ebd69b29a80b01f06a9c71b34f /nptl
parent3ff2c948beaad303e376e1ad778d1cd8693a3099 (diff)
downloadglibc-8ccf22f93431a2f8c77de708cd3b15325c8fe0f4.tar.gz
glibc-8ccf22f93431a2f8c77de708cd3b15325c8fe0f4.tar.xz
glibc-8ccf22f93431a2f8c77de708cd3b15325c8fe0f4.zip
* include/rpc/clnt.h: Declare __libc_clntudp_bufcreate and
	__libc_clntudp_bufcreate_internal.
	* include/sys/socket.h: Declare __have_sock_cloexec.
	* socket/Makefile (aux): Add have_sock_cloexec.
	* socket/have_sock_cloexec.c: New file.
	* sunrpc/clnt_udp.h (clntudp_bufcreate): Now a wrapper around
	__libc_clntudp_bufcreate.
	(__libc_clntudp_bufcreate): Former implementation of clntudp_bufcreate
	which takes an additional parameter.  Create socket with non-blocking
	mode and close-on-exec flag set, if wanted.
	* sunrpc/Versions: Export __libc_clntudp_bufcreate@GLIBC_PRIVATE.
	* nis/ypclnt.c (yp_bind_client_create): Use __libc_clntpudp_bufcreate
	instead of clntudp_create.  The socket has already the close-on-exec
	flag set if SOCK_CLOEXEC is defined.
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog13
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mq_notify.c29
2 files changed, 38 insertions, 4 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 744f90d786..27ced1aedb 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,14 @@
+2008-07-25  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/unix/sysv/linux/mq_notify.c (init_mq_netlink): Use
+	SOCK_CLOEXEC if possible.
+
+2008-05-29  Ulrich Drepper  <drepper@redhat.com>
+
+	* Makefile (tests): Add tst-rwlock2a.
+	* tst-rwlock2.c: Use TYPE macro to decide what rwlock type to use.
+	* tst-rwlock2a.c: New file.
+
 2008-06-12  Ulrich Drepper  <drepper@redhat.com>
 
 	* sysdeps/pthread/pthread.h: Remove inadvertant checkin.
@@ -76,7 +87,7 @@
 
 2008-03-27  Ulrich Drepper  <drepper@redhat.com>
 
-	* sysdeps/unix/sysv/linux/bits/local_lim.h: Undefined ARG_MAX if
+	* sysdeps/unix/sysv/linux/bits/local_lim.h: Undefine ARG_MAX if
 	<linux/limits.h> has defined it.
 	* sysdeps/unix/sysv/linux/alpha/bits/local_lim.h: Likewise.
 	* sysdeps/unix/sysv/linux/ia64/bits/local_lim.h: Likewise.
diff --git a/nptl/sysdeps/unix/sysv/linux/mq_notify.c b/nptl/sysdeps/unix/sysv/linux/mq_notify.c
index 2ec11bf686..1be452a0e0 100644
--- a/nptl/sysdeps/unix/sysv/linux/mq_notify.c
+++ b/nptl/sysdeps/unix/sysv/linux/mq_notify.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2005, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contribute by Ulrich Drepper <drepper@redhat.com>, 2004.
 
@@ -29,6 +29,7 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <not-cancel.h>
+#include <kernel-features.h>
 
 
 #ifdef __NR_mq_notify
@@ -152,18 +153,40 @@ 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.  */
-      netlink_socket = socket (AF_NETLINK, SOCK_RAW, 0);
+      if (have_sock_cloexec)
+	{
+	  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);
       /* No need to do more if we have no socket.  */
       if (netlink_socket == -1)
 	return;
 
       /* Make sure the descriptor is closed on exec.  */
-      if (fcntl (netlink_socket, F_SETFD, FD_CLOEXEC) != 0)
+      if (have_sock_cloexec < 0
+	  && fcntl (netlink_socket, F_SETFD, FD_CLOEXEC) != 0)
 	goto errout;
     }