]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - hurd/hurdsock.c
Pass -nostdlib -nostartfiles together with -r [BZ #31753]
[thirdparty/glibc.git] / hurd / hurdsock.c
index 4b32ad431435a0d62133c5156913fb77d3c5c62e..16bca5e7d767bff83623d1e71b1e2e4eb967918b 100644 (file)
@@ -1,5 +1,5 @@
 /* _hurd_socket_server - Find the server for a socket domain.
-   Copyright (C) 1991-2012 Free Software Foundation, Inc.
+   Copyright (C) 1991-2024 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
@@ -14,7 +14,7 @@
 
    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/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #include <hurd.h>
 #include <sys/socket.h>
@@ -23,8 +23,9 @@
 #include <hurd/paths.h>
 #include <stdio.h>
 #include <_itoa.h>
-#include <cthreads.h>          /* For `struct mutex'.  */
+#include <lock-intern.h>       /* For `struct mutex'.  */
 #include "hurdmalloc.h"                /* XXX */
+#include "set-hooks.h"
 
 static struct mutex lock;
 
@@ -47,11 +48,9 @@ _hurd_socket_server (int domain, int dead)
   socket_t server;
 
   if (domain < 0)
-    {
-      errno = EAFNOSUPPORT;
-      return MACH_PORT_NULL;
-    }
+    return __hurd_fail (EAFNOSUPPORT), MACH_PORT_NULL;
 
+retry:
   HURD_CRITICAL_BEGIN;
   __mutex_lock (&lock);
 
@@ -97,15 +96,18 @@ _hurd_socket_server (int domain, int dead)
 
   if (server == MACH_PORT_NULL && errno == ENOENT)
     /* If the server node is absent, we don't support that protocol.  */
-    errno = EAFNOSUPPORT;
+    __hurd_fail (EAFNOSUPPORT);
 
   __mutex_unlock (&lock);
   HURD_CRITICAL_END;
+  if (server == MACH_PORT_NULL && errno == EINTR)
+    /* Got a signal while inside an RPC of the critical section, retry again */
+    goto retry;
 
   return server;
 }
 \f
-static void
+static void attribute_used_retain
 init (void)
 {
   int i;
@@ -114,7 +116,5 @@ init (void)
 
   for (i = 0; i < max_domain; ++i)
     servers[i] = MACH_PORT_NULL;
-
-  (void) &init;                        /* Avoid "defined but not used" warning.  */
 }
-text_set_element (_hurd_preinit_hook, init);
+SET_RELHOOK (_hurd_preinit_hook, init);