This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.19-902-gb0f955c


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  b0f955c9ac70181532e93aa78c49c204c2a31dfd (commit)
      from  45ef66289acbab17278a73512f9b2a9d8a7ca79d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=b0f955c9ac70181532e93aa78c49c204c2a31dfd

commit b0f955c9ac70181532e93aa78c49c204c2a31dfd
Author: Samuel Thibault <samuel.thibault@gnu.org>
Date:   Thu Aug 28 00:11:54 2014 +0200

    Simplify atomicity of socket creation in bind.

diff --git a/ChangeLog b/ChangeLog
index 6261ed4..8d1eef4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-08-27  Samuel Thibault  <samuel.thibault@ens-lyon.org>
+
+	Simplify atomicity of socket creation in bind.
+
+	* sysdeps/mach/hurd/bind.c (__bind): Use dir_lookup(node, "") instead of
+	looking up the name after linking the file.
+
 2014-08-27  Allan McRae  <allan@archlinux.org>
 
 	* sysdeps/i386/fpu/libm-test-ulps: Update ULPs.
diff --git a/sysdeps/mach/hurd/bind.c b/sysdeps/mach/hurd/bind.c
index 17ef22a..9bd668c 100644
--- a/sysdeps/mach/hurd/bind.c
+++ b/sysdeps/mach/hurd/bind.c
@@ -39,7 +39,7 @@ __bind  (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)
     {
       /* For the local domain, we must create a node in the filesystem
 	 using the ifsock translator and then fetch the address from it.  */
-      file_t dir, node;
+      file_t dir, node, ifsock;
       char name[len - offsetof (struct sockaddr_un, sun_path) + 1], *n;
 
       strncpy (name, addr->sun_path, sizeof name - 1);
@@ -63,36 +63,32 @@ __bind  (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)
 				       MACH_MSG_TYPE_COPY_SEND);
 	  if (! err)
 	    {
-	      /* Link the node, now a socket, into the target directory.  */
-	      err = __dir_link (dir, node, n, 1);
-	      if (err == EEXIST)
+	      enum retry_type doretry;
+	      char retryname[1024];
+	      /* Get a port to the ifsock translator.  */
+	      err = __dir_lookup (node, "", 0, 0, &doretry, retryname, &ifsock);
+	      if (! err && (doretry != FS_RETRY_NORMAL || retryname[0] != '\0'))
 		err = EADDRINUSE;
 	    }
-	  __mach_port_deallocate (__mach_task_self (), node);
 	  if (! err)
 	    {
-	      /* Get a port to the ifsock translator.  */
-	      file_t ifsock = __file_name_lookup_under (dir, n, 0, 0);
-	      if (ifsock == MACH_PORT_NULL)
+	      /* Get the address port.  */
+	      err = __ifsock_getsockaddr (ifsock, &aport);
+	      if (err == MIG_BAD_ID || err == EOPNOTSUPP)
+		err = EGRATUITOUS;
+	      if (! err)
 		{
-		  err = errno;
-		  /* If we failed, get rid of the node we created.  */
-		  __dir_unlink (dir, n);
-		}
-	      else
-		{
-		  /* Get the address port.  */
-		  err = __ifsock_getsockaddr (ifsock, &aport);
-		  if (err == MIG_BAD_ID || err == EOPNOTSUPP)
-		    /* We are not talking to /hurd/ifsock.  Probably
-		       someone came in after we linked our node, unlinked
-		       it, and replaced it with a different node, before we
-		       did our lookup.  Treat it as if our link had failed
-		       with EEXIST.  */
+		  /* Link the node, now a socket with proper mode, into the
+		     target directory.  */
+		  err = __dir_link (dir, node, n, 1);
+		  if (err == EEXIST)
 		    err = EADDRINUSE;
+		  if (err)
+		    __mach_port_deallocate (__mach_task_self (), aport);
 		}
 	      __mach_port_deallocate (__mach_task_self (), ifsock);
 	    }
+	  __mach_port_deallocate (__mach_task_self (), node);
 	}
       __mach_port_deallocate (__mach_task_self (), dir);
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                |    7 +++++++
 sysdeps/mach/hurd/bind.c |   40 ++++++++++++++++++----------------------
 2 files changed, 25 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]