mirror of
https://sourceware.org/git/glibc.git
synced 2025-12-24 17:51:17 +03:00
Fix nptl semaphore cleanup invocation.
This commit is contained in:
@@ -37,6 +37,20 @@ __sem_wait_cleanup (void *arg)
|
||||
atomic_decrement (&isem->nwaiters);
|
||||
}
|
||||
|
||||
/* This is in a seperate function in order to make sure gcc
|
||||
puts the call site into an exception region, and thus the
|
||||
cleanups get properly run. */
|
||||
static int
|
||||
__attribute__ ((noinline))
|
||||
do_futex_wait (struct new_sem *isem)
|
||||
{
|
||||
int err, oldtype = __pthread_enable_asynccancel ();
|
||||
|
||||
err = lll_futex_wait (&isem->value, 0, isem->private ^ FUTEX_PRIVATE_FLAG);
|
||||
|
||||
__pthread_disable_asynccancel (oldtype);
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
__new_sem_wait (sem_t *sem)
|
||||
@@ -53,15 +67,7 @@ __new_sem_wait (sem_t *sem)
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Enable asynchronous cancellation. Required by the standard. */
|
||||
int oldtype = __pthread_enable_asynccancel ();
|
||||
|
||||
err = lll_futex_wait (&isem->value, 0,
|
||||
isem->private ^ FUTEX_PRIVATE_FLAG);
|
||||
|
||||
/* Disable asynchronous cancellation. */
|
||||
__pthread_disable_asynccancel (oldtype);
|
||||
|
||||
err = do_futex_wait(isem);
|
||||
if (err != 0 && err != -EWOULDBLOCK)
|
||||
{
|
||||
__set_errno (-err);
|
||||
|
||||
Reference in New Issue
Block a user