aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd/setitimer.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2021-03-23 22:38:54 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2021-03-23 22:40:10 +0000
commitc3b287be74e12bdb15ed36e98d24fd42f8ee9122 (patch)
tree82a9f85685a35bf5b12e480ee6ed1abc24103dc8 /sysdeps/mach/hurd/setitimer.c
parenta4ea18ec6cc3f1370efab09bc18c1badbf74aa13 (diff)
downloadglibc-c3b287be74e12bdb15ed36e98d24fd42f8ee9122.tar
glibc-c3b287be74e12bdb15ed36e98d24fd42f8ee9122.tar.gz
glibc-c3b287be74e12bdb15ed36e98d24fd42f8ee9122.tar.bz2
glibc-c3b287be74e12bdb15ed36e98d24fd42f8ee9122.zip
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.
Diffstat (limited to 'sysdeps/mach/hurd/setitimer.c')
-rw-r--r--sysdeps/mach/hurd/setitimer.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c
index e23e79a63e..4931644db5 100644
--- a/sysdeps/mach/hurd/setitimer.c
+++ b/sysdeps/mach/hurd/setitimer.c
@@ -339,6 +339,7 @@ __setitimer (enum __itimer_which which, const struct itimerval *new,
struct itimerval *old)
{
void *crit;
+ int ret;
switch (which)
{
@@ -353,9 +354,15 @@ __setitimer (enum __itimer_which which, const struct itimerval *new,
break;
}
+retry:
crit = _hurd_critical_section_lock ();
__spin_lock (&_hurd_itimer_lock);
- return setitimer_locked (new, old, crit, 0);
+ ret = setitimer_locked (new, old, crit, 0);
+ if (ret == -1 && errno == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry again */
+ goto retry;
+
+ return ret;
}
static void