{
int i;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_dtable_lock);
/* This fd has a ctty-special port. We need a new one, to tell
the io server of our different process group. */
io_t new;
- if (__term_open_ctty (port, _hurd_pid, _hurd_pgrp, &new))
- new = MACH_PORT_NULL;
+ error_t err;
+ if ((err = __term_open_ctty (port, _hurd_pid, _hurd_pgrp, &new)))
+ {
+ if (err == EINTR)
+ {
+ /* Got a signal while inside an RPC of the critical section,
+ retry. */
+ __mutex_unlock (&_hurd_dtable_lock);
+ HURD_CRITICAL_UNLOCK;
+ goto retry;
+ }
+ new = MACH_PORT_NULL;
+ }
_hurd_port_set (&d->ctty, new);
}
int nuids;
void *crit;
+retry:
crit = _hurd_critical_section_lock ();
__mutex_lock (&_hurd_id.lock);
{
__mutex_unlock (&_hurd_id.lock);
_hurd_critical_section_unlock (crit);
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
return __hurd_fail (err);
}
{ void *__hurd_critical__ = _hurd_critical_section_lock ()
#define HURD_CRITICAL_END \
_hurd_critical_section_unlock (__hurd_critical__); } while (0)
+
+/* This one can be used inside the C scoping level, for early exits. */
+#define HURD_CRITICAL_UNLOCK \
+ _hurd_critical_section_unlock (__hurd_critical__);
\f
/* Initialize the signal code, and start the signal thread.
Arguments give the "init ints" from exec_startup. */
ss = _hurd_self_sigstate ();
+retry:
assert (! __spin_lock_locked (&ss->critical_section_lock));
__spin_lock (&ss->critical_section_lock);
/* Safe to let signals happen now. */
_hurd_critical_section_unlock (ss);
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
outargs:
free (args);
if (!d)
return __hurd_fail (EBADF);
+retry:
HURD_CRITICAL_BEGIN;
ret = HURD_PORT_USE (&d->port,
}));
HURD_CRITICAL_END;
+ if (ret == -1 && errno == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
return ret;
}
return MACH_PORT_NULL;
}
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&lock);
__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. */
+ goto retry;
return server;
}
for (i = 0; i < n; ++i)
new[i] = uids[i];
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
err = _hurd_check_ids ();
}
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
return __hurd_fail (err);
rcrdir = rcwdir = MACH_PORT_NULL;
+ retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (rcrdir != MACH_PORT_NULL)
__mach_port_deallocate (__mach_task_self (), rcrdir);
RUN_HOOK (_hurd_atfork_prepare_hook, ());
ss = _hurd_self_sigstate ();
+retry:
__spin_lock (&ss->critical_section_lock);
#undef LOSE
}
_hurd_critical_section_unlock (ss);
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (!err)
{
error_t err;
gid_t egid;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (egid == -1 && errno == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
return egid;
}
error_t err;
uid_t euid;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (euid == -1 && errno == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
return euid;
}
error_t err;
gid_t gid;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (gid == -1 && errno == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
return gid;
}
if (n < 0)
return __hurd_fail (EINVAL);
+retry:
crit = _hurd_critical_section_lock ();
__mutex_lock (&_hurd_id.lock);
{
__mutex_unlock (&_hurd_id.lock);
_hurd_critical_section_unlock (crit);
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
return __hurd_fail (err);
}
{
error_t err;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
return __hurd_fail (err);
}
{
error_t err;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
return __hurd_fail (err);
}
error_t err;
uid_t uid;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (uid == -1 && errno == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
return uid;
}
error_t err;
void *crit;
+retry:
crit = _hurd_critical_section_lock ();
__mutex_lock (&_hurd_id.lock);
__mutex_unlock (&_hurd_id.lock);
_hurd_critical_section_unlock (crit);
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
__hurd_fail (err);
auth_t newauth;
error_t err;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
err = _hurd_check_ids ();
}
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
return __hurd_fail (err);
auth_t newauth;
error_t err;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
err = _hurd_check_ids ();
}
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
return __hurd_fail (err);
auth_t newauth;
error_t err;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
err = _hurd_check_ids ();
}
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
return __hurd_fail (err);
for (i = 0; i < n; ++i)
new[i] = groups[i];
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
err = _hurd_check_ids ();
}
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
return __hurd_fail (err);
struct itimerval *old)
{
void *crit;
+ int ret;
switch (which)
{
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. */
+ goto retry;
+
+ return ret;
}
\f
static void
auth_t newauth;
error_t err;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
err = _hurd_check_ids ();
}
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
return __hurd_fail (err);
auth_t newauth;
error_t err;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
err = _hurd_check_ids ();
}
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
return __hurd_fail (err);
auth_t newauth;
error_t err;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
err = _hurd_check_ids ();
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
return __hurd_fail (err);
auth_t newauth;
error_t err;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
err = _hurd_check_ids ();
}
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
return __hurd_fail (err);
error_t err;
unsigned int stamp;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_dtable_lock);
}
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
return err ? __hurd_fail (err) : _hurd_pgrp;
}
auth_t newauth;
error_t err;
+retry:
HURD_CRITICAL_BEGIN;
__mutex_lock (&_hurd_id.lock);
err = _hurd_check_ids ();
}
__mutex_unlock (&_hurd_id.lock);
HURD_CRITICAL_END;
+ if (err == EINTR)
+ /* Got a signal while inside an RPC of the critical section, retry. */
+ goto retry;
if (err)
return __hurd_fail (err);
ss = _hurd_self_sigstate ();
+retry:
assert (! __spin_lock_locked (&ss->critical_section_lock));
__spin_lock (&ss->critical_section_lock);
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. */
+ __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