From c3b287be74e12bdb15ed36e98d24fd42f8ee9122 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 23 Mar 2021 22:38:54 +0000 Subject: hurd: handle EINTR during critical sections During critical sections, signal handling is deferred and thus RPCs return EINTR, even if SA_RESTART is set. We thus have to restart the whole critical section in that case. This also adds HURD_CRITICAL_UNLOCK in the cases where one wants to break the section in the middle. --- sysdeps/mach/hurd/spawni.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'sysdeps/mach/hurd/spawni.c') diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c index 9bc1571c29..b5c92365f2 100644 --- a/sysdeps/mach/hurd/spawni.c +++ b/sysdeps/mach/hurd/spawni.c @@ -333,6 +333,7 @@ __spawni (pid_t *pid, const char *file, ss = _hurd_self_sigstate (); +retry: assert (! __spin_lock_locked (&ss->critical_section_lock)); __spin_lock (&ss->critical_section_lock); @@ -437,7 +438,19 @@ __spawni (pid_t *pid, const char *file, MACH_PORT_RIGHT_SEND, +1)); if (err) - goto out; + { + _hurd_critical_section_unlock (ss); + + if (err == EINTR) + { + /* Got a signal while inside an RPC of the critical section, retry again */ + __mach_port_deallocate (__mach_task_self (), auth); + auth = MACH_PORT_NULL; + goto retry; + } + + goto out; + } /* Pack up the descriptor table to give the new program. These descriptors will need to be reauthenticated below -- cgit 1.4.1