[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/15] Hurd signals: make sigsuspend POSIX-conformant.
From: |
Jeremie Koenig |
Subject: |
[PATCH 06/15] Hurd signals: make sigsuspend POSIX-conformant. |
Date: |
Wed, 29 Jun 2011 18:30:18 +0200 |
* hurd/hurdsig.c (wake_sigsuspend): New function.
(post_signal): wake up sigsuspend calls in the "handle" case.
(post_signals): no longer wake up sigsuspend calls indiscriminately.
---
hurd/hurdsig.c | 46 ++++++++++++++++++++++++++++------------------
1 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c
index c8cae6a..0ec0f27 100644
--- a/hurd/hurdsig.c
+++ b/hurd/hurdsig.c
@@ -443,6 +443,30 @@ abort_all_rpcs (int signo, struct machine_thread_all_state
*state, int live)
}
}
+/* Wake up any sigsuspend call that is blocking SS->thread. SS must be
+ locked. */
+static void
+wake_sigsuspend (struct hurd_sigstate *ss)
+{
+ error_t err;
+ mach_msg_header_t msg;
+
+ if (ss->suspended == MACH_PORT_NULL)
+ return;
+
+ /* There is a sigsuspend waiting. Tell it to wake up. */
+ msg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0);
+ msg.msgh_remote_port = ss->suspended;
+ msg.msgh_local_port = MACH_PORT_NULL;
+ /* These values do not matter. */
+ msg.msgh_id = 8675309; /* Jenny, Jenny. */
+ ss->suspended = MACH_PORT_NULL;
+ err = __mach_msg (&msg, MACH_SEND_MSG, sizeof msg, 0,
+ MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE,
+ MACH_PORT_NULL);
+ assert_perror (err);
+}
+
struct hurd_signal_preemptor *_hurdsig_preemptors = 0;
sigset_t _hurdsig_preempted_set;
@@ -933,6 +957,9 @@ post_signal (struct hurd_sigstate *ss,
&& signo != SIGILL && signo != SIGTRAP)
ss->actions[signo].sa_handler = SIG_DFL;
+ /* Any sigsuspend call must return after the handler does. */
+ wake_sigsuspend (ss);
+
/* Start the thread running the handler (or possibly waiting for an
RPC reply before running the handler). */
err = __thread_set_state (ss->thread, MACHINE_THREAD_STATE_FLAVOR,
@@ -985,24 +1012,7 @@ post_pending (struct hurd_sigstate *ss, sigset_t pending,
void (*reply) (void))
return 0;
}
- /* No more signals pending; SS->lock is still locked.
- Wake up any sigsuspend call that is blocking SS->thread. */
- if (ss->suspended != MACH_PORT_NULL)
- {
- /* There is a sigsuspend waiting. Tell it to wake up. */
- error_t err;
- mach_msg_header_t msg;
- msg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0);
- msg.msgh_remote_port = ss->suspended;
- msg.msgh_local_port = MACH_PORT_NULL;
- /* These values do not matter. */
- msg.msgh_id = 8675309; /* Jenny, Jenny. */
- ss->suspended = MACH_PORT_NULL;
- err = __mach_msg (&msg, MACH_SEND_MSG, sizeof msg, 0,
- MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE,
- MACH_PORT_NULL);
- assert_perror (err);
- }
+ /* No more signals pending; SS->lock is still locked. */
__spin_unlock (&ss->lock);
return 1;
--
1.7.5.3
- [PATCH 00/15] Hurd signals: please review, Jeremie Koenig, 2011/06/29
- [PATCH 01/15] _hurd_internal_post_signal: Split into more functions, Jeremie Koenig, 2011/06/29
- [PATCH 02/15] _hurd_internal_post_signal: Scope variables more restrictively, Jeremie Koenig, 2011/06/29
- [PATCH 06/15] Hurd signals: make sigsuspend POSIX-conformant.,
Jeremie Koenig <=
- [PATCH 05/15] Hurd signals: reindent, Jeremie Koenig, 2011/06/29
- [PATCH 08/15] Versions.def: add GLIBC_2.15, Jeremie Koenig, 2011/06/29
- [PATCH 10/15] Hurd signals: provide a sigstate destructor, Jeremie Koenig, 2011/06/29
- [PATCH 11/15] Hurd signals: fix sigwait() for global signals, Jeremie Koenig, 2011/06/29
- [PATCH 14/15] Hurd signals: SA_SIGINFO support, Jeremie Koenig, 2011/06/29
- [PATCH 13/15] Hurd signals: Copy bits/sigaction.h, Jeremie Koenig, 2011/06/29
- [PATCH 07/15] Hurd signals: fix uninitialized value., Jeremie Koenig, 2011/06/29
- [PATCH 04/15] Hurd signals: refactor check_pending_signals, Jeremie Koenig, 2011/06/29
- [PATCH 03/15] _hurd_internal_post_signal: Split out inner functions, Jeremie Koenig, 2011/06/29
- [PATCH 09/15] Hurd signals: implement global signal dispositions, Jeremie Koenig, 2011/06/29