/* _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
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>
#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;
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);
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;
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);