1995-08-14 22:49:23 +00:00
|
|
|
/* Replacement for mach_msg used in interruptible Hurd RPCs.
|
2023-01-06 21:08:04 +00:00
|
|
|
Copyright (C) 1995-2023 Free Software Foundation, Inc.
|
1997-02-15 04:31:36 +00:00
|
|
|
This file is part of the GNU C Library.
|
1995-08-14 22:49:23 +00:00
|
|
|
|
1997-02-15 04:31:36 +00:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1995-08-14 22:49:23 +00:00
|
|
|
|
1997-02-15 04:31:36 +00:00
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1995-08-14 22:49:23 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
1995-08-14 22:49:23 +00:00
|
|
|
|
|
|
|
#include <mach.h>
|
2023-05-06 20:55:10 +00:00
|
|
|
#include <mach_rpc.h>
|
1995-08-14 22:49:23 +00:00
|
|
|
#include <mach/mig_errors.h>
|
1996-01-04 10:00:22 +00:00
|
|
|
#include <mach/mig_support.h>
|
1995-08-14 22:49:23 +00:00
|
|
|
#include <hurd/signal.h>
|
1999-08-22 22:23:58 +00:00
|
|
|
#include <assert.h>
|
1995-08-14 22:49:23 +00:00
|
|
|
|
1995-08-17 22:55:22 +00:00
|
|
|
#include "intr-msg.h"
|
|
|
|
|
2002-02-18 20:57:51 +00:00
|
|
|
#ifdef NDR_CHAR_ASCII /* OSF Mach flavors have different names. */
|
|
|
|
# define mig_reply_header_t mig_reply_error_t
|
|
|
|
#endif
|
1995-08-17 22:55:22 +00:00
|
|
|
|
1995-08-14 22:49:23 +00:00
|
|
|
error_t
|
|
|
|
_hurd_intr_rpc_mach_msg (mach_msg_header_t *msg,
|
|
|
|
mach_msg_option_t option,
|
|
|
|
mach_msg_size_t send_size,
|
|
|
|
mach_msg_size_t rcv_size,
|
|
|
|
mach_port_t rcv_name,
|
|
|
|
mach_msg_timeout_t timeout,
|
|
|
|
mach_port_t notify)
|
|
|
|
{
|
|
|
|
error_t err;
|
1998-10-18 23:19:12 +00:00
|
|
|
struct hurd_sigstate *ss;
|
1999-08-22 22:23:58 +00:00
|
|
|
const mach_msg_option_t user_option = option;
|
|
|
|
const mach_msg_timeout_t user_timeout = timeout;
|
|
|
|
|
2002-02-18 20:57:51 +00:00
|
|
|
struct clobber
|
|
|
|
{
|
|
|
|
#ifdef NDR_CHAR_ASCII
|
|
|
|
NDR_record_t ndr;
|
|
|
|
#else
|
|
|
|
mach_msg_type_t type;
|
|
|
|
#endif
|
|
|
|
error_t err;
|
|
|
|
};
|
1999-08-22 22:23:58 +00:00
|
|
|
union msg
|
|
|
|
{
|
|
|
|
mach_msg_header_t header;
|
|
|
|
mig_reply_header_t reply;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
mach_msg_header_t header;
|
2002-02-18 20:57:51 +00:00
|
|
|
#ifdef NDR_CHAR_ASCII
|
|
|
|
NDR_record_t ndr;
|
|
|
|
#else
|
2023-05-04 04:08:12 +00:00
|
|
|
mach_msg_type_t type;
|
2002-02-18 20:57:51 +00:00
|
|
|
#endif
|
1999-08-22 22:23:58 +00:00
|
|
|
int code;
|
|
|
|
} check;
|
|
|
|
struct
|
1998-10-18 23:19:12 +00:00
|
|
|
{
|
1999-08-22 22:23:58 +00:00
|
|
|
mach_msg_header_t header;
|
|
|
|
struct clobber data;
|
|
|
|
} request;
|
|
|
|
};
|
|
|
|
union msg *const m = (void *) msg;
|
|
|
|
mach_msg_bits_t msgh_bits;
|
|
|
|
mach_port_t remote_port;
|
|
|
|
mach_msg_id_t msgid;
|
|
|
|
struct clobber save_data;
|
|
|
|
|
|
|
|
if ((option & (MACH_SEND_MSG|MACH_RCV_MSG)) != (MACH_SEND_MSG|MACH_RCV_MSG)
|
|
|
|
|| _hurd_msgport_thread == MACH_PORT_NULL)
|
|
|
|
{
|
|
|
|
/* Either this is not an RPC (i.e., only a send or only a receive),
|
|
|
|
so it can't be interruptible; or, the signal thread is not set up
|
|
|
|
yet, so we cannot do the normal signal magic. Do a normal,
|
|
|
|
uninterruptible mach_msg call instead. */
|
|
|
|
return __mach_msg (&m->header, option, send_size, rcv_size, rcv_name,
|
1998-10-18 23:19:12 +00:00
|
|
|
timeout, notify);
|
|
|
|
}
|
|
|
|
|
|
|
|
ss = _hurd_self_sigstate ();
|
|
|
|
|
1999-08-22 22:23:58 +00:00
|
|
|
/* Save state that gets clobbered by an EINTR reply message.
|
|
|
|
We will need to restore it if we want to retry the RPC. */
|
|
|
|
msgh_bits = m->header.msgh_bits;
|
|
|
|
remote_port = m->header.msgh_remote_port;
|
|
|
|
msgid = m->header.msgh_id;
|
|
|
|
assert (rcv_size >= sizeof m->request);
|
|
|
|
save_data = m->request.data;
|
1995-08-14 22:49:23 +00:00
|
|
|
|
|
|
|
/* Tell the signal thread that we are doing an interruptible RPC on
|
|
|
|
this port. If we get a signal and should return EINTR, the signal
|
|
|
|
thread will set this variable to MACH_PORT_NULL. The RPC might
|
|
|
|
return EINTR when some other thread gets a signal, in which case we
|
|
|
|
want to restart our call. */
|
1999-08-22 22:23:58 +00:00
|
|
|
ss->intr_port = m->header.msgh_remote_port;
|
1996-01-04 10:00:22 +00:00
|
|
|
|
1999-08-22 22:23:58 +00:00
|
|
|
/* A signal may arrive here, after intr_port is set, but before the
|
|
|
|
mach_msg system call. The signal handler might do an interruptible
|
|
|
|
RPC, and clobber intr_port; then it would not be set properly when we
|
|
|
|
actually did send the RPC, and a later signal wouldn't interrupt that
|
|
|
|
RPC. So, _hurd_setup_sighandler saves intr_port in the sigcontext,
|
|
|
|
and sigreturn restores it. */
|
1995-08-14 22:49:23 +00:00
|
|
|
|
|
|
|
message:
|
|
|
|
|
1999-08-22 22:23:58 +00:00
|
|
|
/* Note that the signal trampoline code might modify our OPTION! */
|
1996-01-04 10:00:22 +00:00
|
|
|
err = INTR_MSG_TRAP (msg, option, send_size,
|
2018-10-09 21:40:09 +00:00
|
|
|
rcv_size, rcv_name, timeout, notify,
|
|
|
|
&ss->cancel, &ss->intr_port);
|
1995-08-14 22:49:23 +00:00
|
|
|
|
|
|
|
switch (err)
|
|
|
|
{
|
1995-08-31 00:02:32 +00:00
|
|
|
case MACH_RCV_TIMED_OUT:
|
1999-08-22 22:23:58 +00:00
|
|
|
if (user_option & MACH_RCV_TIMEOUT)
|
1995-08-31 00:02:32 +00:00
|
|
|
/* The real user RPC timed out. */
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
/* The operation was supposedly interrupted, but still has
|
|
|
|
not returned. Declare it interrupted. */
|
2018-10-09 20:25:19 +00:00
|
|
|
goto dead;
|
1995-08-31 00:02:32 +00:00
|
|
|
|
1995-08-14 22:49:23 +00:00
|
|
|
case MACH_SEND_INTERRUPTED: /* RPC didn't get out. */
|
1999-08-22 22:23:58 +00:00
|
|
|
if (!(option & MACH_SEND_MSG))
|
|
|
|
{
|
|
|
|
/* Oh yes, it did! Since we were not doing a message send,
|
|
|
|
this return code cannot have come from the kernel!
|
|
|
|
Instead, it was the signal thread mutating our state to tell
|
|
|
|
us not to enter this RPC. However, we are already in the receive!
|
|
|
|
Since the signal thread thought we weren't in the RPC yet,
|
|
|
|
it didn't do an interrupt_operation.
|
|
|
|
XXX */
|
|
|
|
goto retry_receive;
|
|
|
|
}
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
2000-03-18 08:25:11 +00:00
|
|
|
/* These are the other codes that mean a pseudo-receive modified
|
|
|
|
the message buffer and we might need to clean up the port rights. */
|
|
|
|
case MACH_SEND_TIMED_OUT:
|
|
|
|
case MACH_SEND_INVALID_NOTIFY:
|
2002-02-18 20:57:51 +00:00
|
|
|
#ifdef MACH_SEND_NO_NOTIFY
|
2000-03-18 08:25:11 +00:00
|
|
|
case MACH_SEND_NO_NOTIFY:
|
2002-02-18 20:57:51 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MACH_SEND_NOTIFY_IN_PROGRESS
|
2000-03-18 08:25:11 +00:00
|
|
|
case MACH_SEND_NOTIFY_IN_PROGRESS:
|
2002-02-18 20:57:51 +00:00
|
|
|
#endif
|
2000-03-18 08:25:11 +00:00
|
|
|
if (MACH_MSGH_BITS_REMOTE (msg->msgh_bits) == MACH_MSG_TYPE_MOVE_SEND)
|
|
|
|
{
|
|
|
|
__mach_port_deallocate (__mach_task_self (), msg->msgh_remote_port);
|
|
|
|
msg->msgh_bits
|
|
|
|
= (MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND,
|
|
|
|
MACH_MSGH_BITS_LOCAL (msg->msgh_bits))
|
|
|
|
| MACH_MSGH_BITS_OTHER (msg->msgh_bits));
|
|
|
|
}
|
|
|
|
if (msg->msgh_bits & MACH_MSGH_BITS_COMPLEX)
|
|
|
|
{
|
2002-02-18 20:57:51 +00:00
|
|
|
#ifndef MACH_MSG_PORT_DESCRIPTOR
|
2000-03-18 08:25:11 +00:00
|
|
|
/* Check for MOVE_SEND rights in the message. These hold refs
|
|
|
|
that we need to release in case the message is in fact never
|
|
|
|
re-sent later. Since it might in fact be re-sent, we turn
|
|
|
|
these into COPY_SEND's after deallocating the extra user ref;
|
|
|
|
the caller is responsible for still holding a ref to go with
|
|
|
|
the original COPY_SEND right, so the resend copies it again. */
|
|
|
|
|
|
|
|
mach_msg_type_long_t *ty = (void *) (msg + 1);
|
|
|
|
while ((void *) ty < (void *) msg + msg->msgh_size)
|
|
|
|
{
|
|
|
|
mach_msg_type_name_t name;
|
|
|
|
mach_msg_type_size_t size;
|
|
|
|
mach_msg_type_number_t number;
|
|
|
|
|
|
|
|
inline void clean_ports (mach_port_t *ports, int dealloc)
|
|
|
|
{
|
|
|
|
mach_msg_type_number_t i;
|
|
|
|
switch (name)
|
|
|
|
{
|
|
|
|
case MACH_MSG_TYPE_MOVE_SEND:
|
|
|
|
for (i = 0; i < number; i++)
|
|
|
|
__mach_port_deallocate (__mach_task_self (), *ports++);
|
2005-10-23 00:43:15 +00:00
|
|
|
if (ty->msgtl_header.msgt_longform)
|
|
|
|
ty->msgtl_name = MACH_MSG_TYPE_COPY_SEND;
|
|
|
|
else
|
|
|
|
ty->msgtl_header.msgt_name = MACH_MSG_TYPE_COPY_SEND;
|
2000-03-18 08:25:11 +00:00
|
|
|
break;
|
|
|
|
case MACH_MSG_TYPE_COPY_SEND:
|
|
|
|
case MACH_MSG_TYPE_MOVE_RECEIVE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (MACH_MSG_TYPE_PORT_ANY (name))
|
|
|
|
assert (! "unexpected port type in interruptible RPC");
|
|
|
|
}
|
|
|
|
if (dealloc)
|
|
|
|
__vm_deallocate (__mach_task_self (),
|
|
|
|
(vm_address_t) ports,
|
|
|
|
number * sizeof (mach_port_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ty->msgtl_header.msgt_longform)
|
|
|
|
{
|
|
|
|
name = ty->msgtl_name;
|
|
|
|
size = ty->msgtl_size;
|
|
|
|
number = ty->msgtl_number;
|
2005-10-23 00:43:15 +00:00
|
|
|
ty = (void *) ty + sizeof (mach_msg_type_long_t);
|
2000-03-18 08:25:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name = ty->msgtl_header.msgt_name;
|
|
|
|
size = ty->msgtl_header.msgt_size;
|
|
|
|
number = ty->msgtl_header.msgt_number;
|
2005-10-23 00:43:15 +00:00
|
|
|
ty = (void *) ty + sizeof (mach_msg_type_t);
|
2000-03-18 08:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ty->msgtl_header.msgt_inline)
|
|
|
|
{
|
2023-05-04 04:08:12 +00:00
|
|
|
/* Calculate length of data in bytes. */
|
|
|
|
const vm_size_t length = ((number * size) + 7) >> 3;
|
2000-03-18 08:25:11 +00:00
|
|
|
clean_ports ((void *) ty, 0);
|
2023-05-04 04:08:12 +00:00
|
|
|
/* Move to the next argument. */
|
|
|
|
ty = (void *) PTR_ALIGN_UP ((char *) ty + length,
|
|
|
|
__alignof__ (uintptr_t));
|
2000-03-18 08:25:11 +00:00
|
|
|
}
|
|
|
|
else
|
2001-12-17 01:03:08 +00:00
|
|
|
{
|
|
|
|
clean_ports (*(void **) ty,
|
|
|
|
ty->msgtl_header.msgt_deallocate);
|
2005-10-23 00:43:15 +00:00
|
|
|
ty = (void *) ty + sizeof (void *);
|
2001-12-17 01:03:08 +00:00
|
|
|
}
|
2000-03-18 08:25:11 +00:00
|
|
|
}
|
2002-02-18 20:57:51 +00:00
|
|
|
#else /* Untyped Mach IPC flavor. */
|
|
|
|
mach_msg_body_t *body = (void *) (msg + 1);
|
|
|
|
mach_msg_descriptor_t *desc = (void *) (body + 1);
|
|
|
|
mach_msg_descriptor_t *desc_end = desc + body->msgh_descriptor_count;
|
|
|
|
for (; desc < desc_end; ++desc)
|
|
|
|
switch (desc->type.type)
|
|
|
|
{
|
|
|
|
case MACH_MSG_PORT_DESCRIPTOR:
|
|
|
|
switch (desc->port.disposition)
|
|
|
|
{
|
|
|
|
case MACH_MSG_TYPE_MOVE_SEND:
|
|
|
|
__mach_port_deallocate (mach_task_self (),
|
|
|
|
desc->port.name);
|
|
|
|
desc->port.disposition = MACH_MSG_TYPE_COPY_SEND;
|
|
|
|
break;
|
|
|
|
case MACH_MSG_TYPE_COPY_SEND:
|
|
|
|
case MACH_MSG_TYPE_MOVE_RECEIVE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert (! "unexpected port type in interruptible RPC");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MACH_MSG_OOL_DESCRIPTOR:
|
|
|
|
if (desc->out_of_line.deallocate)
|
|
|
|
__vm_deallocate (__mach_task_self (),
|
|
|
|
(vm_address_t) desc->out_of_line.address,
|
|
|
|
desc->out_of_line.size);
|
|
|
|
break;
|
|
|
|
case MACH_MSG_OOL_PORTS_DESCRIPTOR:
|
|
|
|
switch (desc->ool_ports.disposition)
|
|
|
|
{
|
|
|
|
case MACH_MSG_TYPE_MOVE_SEND:
|
|
|
|
{
|
|
|
|
mach_msg_size_t i;
|
|
|
|
const mach_port_t *ports = desc->ool_ports.address;
|
|
|
|
for (i = 0; i < desc->ool_ports.count; ++i)
|
|
|
|
__mach_port_deallocate (__mach_task_self (), ports[i]);
|
|
|
|
desc->ool_ports.disposition = MACH_MSG_TYPE_COPY_SEND;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MACH_MSG_TYPE_COPY_SEND:
|
|
|
|
case MACH_MSG_TYPE_MOVE_RECEIVE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert (! "unexpected port type in interruptible RPC");
|
|
|
|
}
|
|
|
|
if (desc->ool_ports.deallocate)
|
|
|
|
__vm_deallocate (__mach_task_self (),
|
|
|
|
(vm_address_t) desc->ool_ports.address,
|
|
|
|
desc->ool_ports.count
|
|
|
|
* sizeof (mach_port_t));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert (! "unexpected descriptor type in interruptible RPC");
|
|
|
|
}
|
|
|
|
#endif
|
2000-03-18 08:25:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-08-22 22:23:58 +00:00
|
|
|
case EINTR:
|
|
|
|
/* Either the process was stopped and continued,
|
|
|
|
or the server doesn't support interrupt_operation. */
|
1995-08-14 22:49:23 +00:00
|
|
|
if (ss->intr_port != MACH_PORT_NULL)
|
|
|
|
/* If this signal was for us and it should interrupt calls, the
|
|
|
|
signal thread will have cleared SS->intr_port.
|
|
|
|
Since it's not cleared, the signal was for another thread,
|
|
|
|
or SA_RESTART is set. Restart the interrupted call. */
|
1996-01-04 10:00:22 +00:00
|
|
|
{
|
1999-08-22 22:23:58 +00:00
|
|
|
/* Make sure we have a valid reply port. The one we were using
|
|
|
|
may have been destroyed by interruption. */
|
2023-04-29 20:18:19 +00:00
|
|
|
__mig_dealloc_reply_port (rcv_name);
|
1999-08-22 22:23:58 +00:00
|
|
|
m->header.msgh_local_port = rcv_name = __mig_get_reply_port ();
|
|
|
|
m->header.msgh_bits = msgh_bits;
|
|
|
|
option = user_option;
|
|
|
|
timeout = user_timeout;
|
1996-01-04 10:00:22 +00:00
|
|
|
goto message;
|
|
|
|
}
|
2018-10-09 20:25:19 +00:00
|
|
|
err = EINTR;
|
|
|
|
|
|
|
|
/* The EINTR return indicates cancellation, so clear the flag. */
|
|
|
|
ss->cancel = 0;
|
|
|
|
break;
|
1995-08-14 22:49:23 +00:00
|
|
|
|
|
|
|
case MACH_RCV_PORT_DIED:
|
|
|
|
/* Server didn't respond to interrupt_operation,
|
|
|
|
so the signal thread destroyed the reply port. */
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
2018-10-09 20:25:19 +00:00
|
|
|
dead:
|
2018-10-29 17:57:13 +00:00
|
|
|
err = EIEIO;
|
1995-08-14 22:49:23 +00:00
|
|
|
|
2018-10-29 17:57:13 +00:00
|
|
|
/* The EIEIO return indicates cancellation, so clear the flag. */
|
1995-08-14 22:49:23 +00:00
|
|
|
ss->cancel = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACH_RCV_INTERRUPTED: /* RPC sent; no reply. */
|
|
|
|
option &= ~MACH_SEND_MSG; /* Don't send again. */
|
1999-08-22 22:23:58 +00:00
|
|
|
retry_receive:
|
1995-08-14 22:49:23 +00:00
|
|
|
if (ss->intr_port == MACH_PORT_NULL)
|
|
|
|
{
|
|
|
|
/* This signal or cancellation was for us. We need to wait for
|
|
|
|
the reply, but not hang forever. */
|
|
|
|
option |= MACH_RCV_TIMEOUT;
|
1995-08-31 00:02:32 +00:00
|
|
|
/* Never decrease the user's timeout. */
|
1999-08-22 22:23:58 +00:00
|
|
|
if (!(user_option & MACH_RCV_TIMEOUT)
|
|
|
|
|| timeout > _hurd_interrupted_rpc_timeout)
|
1995-08-31 00:02:32 +00:00
|
|
|
timeout = _hurd_interrupted_rpc_timeout;
|
1995-08-14 22:49:23 +00:00
|
|
|
}
|
1999-08-22 22:23:58 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
option = user_option;
|
|
|
|
timeout = user_timeout;
|
|
|
|
}
|
1995-08-14 22:49:23 +00:00
|
|
|
goto message; /* Retry the receive. */
|
|
|
|
|
|
|
|
case MACH_MSG_SUCCESS:
|
1999-08-22 22:23:58 +00:00
|
|
|
{
|
|
|
|
/* We got a reply. Was it EINTR? */
|
2002-02-18 20:57:51 +00:00
|
|
|
#ifdef MACH_MSG_TYPE_BIT
|
2023-05-04 04:08:12 +00:00
|
|
|
static const mach_msg_type_t type_check = {
|
|
|
|
.msgt_name = MACH_MSG_TYPE_INTEGER_T,
|
|
|
|
.msgt_size = sizeof (integer_t) * 8,
|
|
|
|
.msgt_number = 1,
|
|
|
|
.msgt_inline = TRUE,
|
|
|
|
.msgt_longform = FALSE,
|
|
|
|
.msgt_deallocate = FALSE,
|
|
|
|
.msgt_unused = 0
|
|
|
|
};
|
2002-02-18 20:57:51 +00:00
|
|
|
#endif
|
1999-08-22 22:23:58 +00:00
|
|
|
|
Break some lines before not after operators.
The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one. This patch fixes various
code to do this. It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting. It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups). Some files changed are shared with
gnulib, but most are specific to glibc. Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).
This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).
Tested for x86_64, and with build-many-glibcs.py.
* benchtests/bench-memmem.c (simple_memmem): Break lines before
rather than after operators.
* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
* crypt/md5.c (md5_finish_ctx): Likewise.
* crypt/sha256.c (__sha256_finish_ctx): Likewise.
* crypt/sha512.c (__sha512_finish_ctx): Likewise.
* elf/cache.c (load_aux_cache): Likewise.
* elf/dl-load.c (open_verify): Likewise.
* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
* elf/readelflib.c (process_elf_file): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/sprof.c (generate_call_graph): Likewise.
* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
* hurd/dtable.c (reauth_dtable): Likewise.
* hurd/getdport.c (__getdport): Likewise.
* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
Likewise.
* hurd/hurdioctl.c (fioctl): Likewise.
* hurd/hurdselect.c (_hurd_select): Likewise.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
(STOPSIGS): Likewise.
* hurd/hurdstartup.c (_hurd_startup): Likewise.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
* hurd/msgportdemux.c (msgport_server): Likewise.
* hurd/setauth.c (_hurd_setauth): Likewise.
* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
* login/tst-utmp.c (do_check): Likewise.
(simulate_login): Likewise.
* mach/lowlevellock.h (lll_lock): Likewise.
(lll_trylock): Likewise.
* math/test-fenv.c (ALL_EXC): Likewise.
* math/test-fenvinline.c (ALL_EXC): Likewise.
* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
* nis/nis_call.c (__do_niscall3): Likewise.
* nis/nis_callback.c (cb_prog_1): Likewise.
* nis/nis_defaults.c (searchaccess): Likewise.
* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
* nis/nis_ismember.c (internal_ismember): Likewise.
* nis/nis_local_names.c (nis_local_principal): Likewise.
* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
Likewise.
* nis/ypclnt.c (yp_match): Likewise.
(yp_first): Likewise.
(yp_next): Likewise.
(yp_master): Likewise.
(yp_order): Likewise.
* nscd/hstcache.c (cache_addhst): Likewise.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
(internal_getpwuid_r): Likewise.
* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
* posix/glob.h (__GLOB_FLAGS): Likewise.
* posix/regcomp.c (peek_token): Likewise.
(peek_token_bracket): Likewise.
(parse_expression): Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
(check_node_accept_bytes): Likewise.
* posix/tst-spawn3.c (do_test): Likewise.
* posix/wordexp-test.c (testit): Likewise.
* posix/wordexp.c (parse_tilde): Likewise.
(exec_comm): Likewise.
* posix/wordexp.h (__WRDE_FLAGS): Likewise.
* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
* setjmp/sigjmp.c (__sigjmp_save): Likewise.
* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
* stdio-common/tst-fileno.c (do_test): Likewise.
* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
* stdlib/strtod_l.c (round_and_return): Likewise.
(____STRTOF_INTERNAL): Likewise.
* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
* string/strcspn.c (STRCSPN): Likewise.
* string/test-memmem.c (simple_memmem): Likewise.
* termios/tcsetattr.c (tcsetattr): Likewise.
* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
* time/asctime.c (asctime_internal): Likewise.
* time/strptime_l.c (__strptime_internal): Likewise.
* time/sys/time.h (timercmp): Likewise.
* time/tzfile.c (__tzfile_compute): Likewise.
2019-02-22 01:32:36 +00:00
|
|
|
if (m->reply.RetCode == EINTR
|
|
|
|
&& m->header.msgh_size == sizeof m->reply
|
2002-02-18 20:57:51 +00:00
|
|
|
#ifdef MACH_MSG_TYPE_BIT
|
2023-05-04 04:08:12 +00:00
|
|
|
&& !BAD_TYPECHECK(&m->check.type, &type_check)
|
2002-02-18 20:57:51 +00:00
|
|
|
#endif
|
Break some lines before not after operators.
The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one. This patch fixes various
code to do this. It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting. It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups). Some files changed are shared with
gnulib, but most are specific to glibc. Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).
This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).
Tested for x86_64, and with build-many-glibcs.py.
* benchtests/bench-memmem.c (simple_memmem): Break lines before
rather than after operators.
* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
* crypt/md5.c (md5_finish_ctx): Likewise.
* crypt/sha256.c (__sha256_finish_ctx): Likewise.
* crypt/sha512.c (__sha512_finish_ctx): Likewise.
* elf/cache.c (load_aux_cache): Likewise.
* elf/dl-load.c (open_verify): Likewise.
* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
* elf/readelflib.c (process_elf_file): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/sprof.c (generate_call_graph): Likewise.
* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
* hurd/dtable.c (reauth_dtable): Likewise.
* hurd/getdport.c (__getdport): Likewise.
* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
Likewise.
* hurd/hurdioctl.c (fioctl): Likewise.
* hurd/hurdselect.c (_hurd_select): Likewise.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
(STOPSIGS): Likewise.
* hurd/hurdstartup.c (_hurd_startup): Likewise.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
* hurd/msgportdemux.c (msgport_server): Likewise.
* hurd/setauth.c (_hurd_setauth): Likewise.
* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
* login/tst-utmp.c (do_check): Likewise.
(simulate_login): Likewise.
* mach/lowlevellock.h (lll_lock): Likewise.
(lll_trylock): Likewise.
* math/test-fenv.c (ALL_EXC): Likewise.
* math/test-fenvinline.c (ALL_EXC): Likewise.
* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
* nis/nis_call.c (__do_niscall3): Likewise.
* nis/nis_callback.c (cb_prog_1): Likewise.
* nis/nis_defaults.c (searchaccess): Likewise.
* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
* nis/nis_ismember.c (internal_ismember): Likewise.
* nis/nis_local_names.c (nis_local_principal): Likewise.
* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
Likewise.
* nis/ypclnt.c (yp_match): Likewise.
(yp_first): Likewise.
(yp_next): Likewise.
(yp_master): Likewise.
(yp_order): Likewise.
* nscd/hstcache.c (cache_addhst): Likewise.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
(internal_getpwuid_r): Likewise.
* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
* posix/glob.h (__GLOB_FLAGS): Likewise.
* posix/regcomp.c (peek_token): Likewise.
(peek_token_bracket): Likewise.
(parse_expression): Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
(check_node_accept_bytes): Likewise.
* posix/tst-spawn3.c (do_test): Likewise.
* posix/wordexp-test.c (testit): Likewise.
* posix/wordexp.c (parse_tilde): Likewise.
(exec_comm): Likewise.
* posix/wordexp.h (__WRDE_FLAGS): Likewise.
* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
* setjmp/sigjmp.c (__sigjmp_save): Likewise.
* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
* stdio-common/tst-fileno.c (do_test): Likewise.
* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
* stdlib/strtod_l.c (round_and_return): Likewise.
(____STRTOF_INTERNAL): Likewise.
* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
* string/strcspn.c (STRCSPN): Likewise.
* string/test-memmem.c (simple_memmem): Likewise.
* termios/tcsetattr.c (tcsetattr): Likewise.
* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
* time/asctime.c (asctime_internal): Likewise.
* time/strptime_l.c (__strptime_internal): Likewise.
* time/sys/time.h (timercmp): Likewise.
* time/tzfile.c (__tzfile_compute): Likewise.
2019-02-22 01:32:36 +00:00
|
|
|
&& !(m->header.msgh_bits & MACH_MSGH_BITS_COMPLEX))
|
1999-08-22 22:23:58 +00:00
|
|
|
{
|
|
|
|
/* It is indeed EINTR. Is the interrupt for us? */
|
|
|
|
if (ss->intr_port != MACH_PORT_NULL)
|
|
|
|
{
|
1995-08-14 22:49:23 +00:00
|
|
|
/* Nope; repeat the RPC.
|
|
|
|
XXX Resources moved? */
|
1999-08-22 22:23:58 +00:00
|
|
|
|
|
|
|
assert (m->header.msgh_id == msgid + 100);
|
|
|
|
|
|
|
|
/* We know we have a valid reply port, because we just
|
|
|
|
received the EINTR reply on it. Restore it and the
|
|
|
|
other fields in the message header needed for send,
|
|
|
|
since the header now reflects receipt of the reply. */
|
|
|
|
m->header.msgh_local_port = rcv_name;
|
|
|
|
m->header.msgh_remote_port = remote_port;
|
|
|
|
m->header.msgh_id = msgid;
|
|
|
|
m->header.msgh_bits = msgh_bits;
|
|
|
|
/* Restore the two words clobbered by the reply data. */
|
|
|
|
m->request.data = save_data;
|
|
|
|
|
|
|
|
/* Restore the original mach_msg options.
|
|
|
|
OPTION may have had MACH_RCV_TIMEOUT added,
|
|
|
|
and/or MACH_SEND_MSG removed. */
|
|
|
|
option = user_option;
|
|
|
|
timeout = user_timeout;
|
|
|
|
|
|
|
|
/* Now we are ready to repeat the original message send. */
|
|
|
|
goto message;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/* The EINTR return indicates cancellation,
|
|
|
|
so clear the flag. */
|
|
|
|
ss->cancel = 0;
|
|
|
|
}
|
|
|
|
}
|
1995-08-14 22:49:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* Quiet -Wswitch-enum. */
|
2001-12-17 01:03:08 +00:00
|
|
|
break;
|
1995-08-14 22:49:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ss->intr_port = MACH_PORT_NULL;
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
hurd: Avoid some libc.so PLTs
* hurd/catch-signal.c (hurd_catch_signal): Rename to
__hurd_catch_signal.
(hurd_catch_signal): New strong alias.
(hurd_safe_memset, hurd_safe_copyout, hurd_safe_copyin): Call
__hurd_catch_signal instead of hurd_catch_signal.
* hurd/exc2signal.c (_hurd_exception2signal): Add hidden def.
* hurd/hurdexec.c (_hurd_init): Add hidden def.
* hurd/hurdinit.c (_hurd_init): Add hidden def.
* hurd/hurdsig.c: Include <mach/mig_support.h>.
(_hurd_thread_sigstate): Add hidden def.
(_hurd_internal_post_signal): Use __mutex_unlock instead of
mutex_unlock.
* hurd/intern-fd.c (_hurd_intern_fd): Add hidden def.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Add hidden def.
* hurd/path-lookup.c (hurd_file_name_path_lookup): Rename to
__hurd_file_name_path_lookup.
(hurd_file_name_path_lookup): New strong alias.
(file_name_path_lookup): Call __hurd_file_name_path_lookup instead of
hurd_file_name_path_lookup.
* mach/errstring.c (mach_error_type): Add hidden def.
* mach/msg-destroy.c (__mach_msg_destroy): Add hidden def.
* mach/mutex-init.c (__mutex_init): Add hidden def.
* mach/spin-lock.c (__spin_lock_locked, __spin_lock, __spin_unlock,
__spin_try_lock, __mutex_lock, __mutex_trylock): Add hidden defs.
* mach/spin-solid.c (__spin_lock_solid): Add hidden def.
* sysdeps/mach/hurd/getcwd.c
(_hurd_canonicalize_directory_name_internal): Rename to
__hurd_canonicalize_directory_name_internal.
(_hurd_canonicalize_directory_name_internal): New strong alias.
(__canonicalize_directory_name_internal, __getcwd): Call
__hurd_canonicalize_directory_name_internal instead of
_hurd_canonicalize_directory_name_internal.
* sysdeps/mach/hurd/mig-reply.c: Include <mach/mig_support.h>.
(__mig_get_reply_port, __mig_dealloc_reply_port, __mig_init): Add
hidden defs.
* sysdeps/hurd/include/hurd.h: New file.
* sysdeps/hurd/include/hurd/fd.h: New file.
* sysdeps/hurd/include/hurd/signal.h: New file.
* sysdeps/mach/include/lock-intern.h: New file.
* sysdeps/mach/include/mach.h: New file.
* sysdeps/mach/include/mach/mig_support.h: New file.
* sysdeps/mach/include/mach_error.h: New file.
2018-04-02 22:07:28 +00:00
|
|
|
libc_hidden_def (_hurd_intr_rpc_mach_msg)
|