From f08c8d9be762cb18a0fc26e98795bde2b785f67e Mon Sep 17 00:00:00 2001 From: Carlos O'Donell Date: Fri, 16 Aug 2013 15:00:53 -0400 Subject: [PATCH] nptl: handle EAGAIN with some futex operations https://bugs.gentoo.org/452184 --- nptl/pthread_mutex_trylock.c | 3 ++- nptl/sem_timedwait.c | 2 +- nptl/sem_wait.c | 4 ++-- sunrpc/clnt_udp.c | 2 +- sysdeps/nptl/aio_misc.h | 4 ++-- sysdeps/nptl/gai_misc.h | 4 ++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index 0867b065331..f10ca582e2a 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -261,7 +261,8 @@ __pthread_mutex_trylock (mutex) private), 0, 0); if (INTERNAL_SYSCALL_ERROR_P (e, __err) - && INTERNAL_SYSCALL_ERRNO (e, __err) == EWOULDBLOCK) + && ((INTERNAL_SYSCALL_ERRNO (e, __err) == EWOULDBLOCK) + || (INTERNAL_SYSCALL_ERRNO (e, __err) == EAGAIN))) { THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL); diff --git a/nptl/sem_timedwait.c b/nptl/sem_timedwait.c index 7dfe51dd8be..f96f6251e21 100644 --- a/nptl/sem_timedwait.c +++ b/nptl/sem_timedwait.c @@ -94,7 +94,7 @@ sem_timedwait (sem_t *sem, const struct timespec *abstime) rt.tv_sec = sec; rt.tv_nsec = nsec; err = do_futex_timed_wait(isem, &rt); - if (err != 0 && err != -EWOULDBLOCK) + if (err != 0 && err != -EWOULDBLOCK && err != -EAGAIN) { __set_errno (-err); err = -1; diff --git a/nptl/sem_wait.c b/nptl/sem_wait.c index b12babb5961..4b9856c8469 100644 --- a/nptl/sem_wait.c +++ b/nptl/sem_wait.c @@ -68,7 +68,7 @@ __new_sem_wait (sem_t *sem) while (1) { err = do_futex_wait(isem); - if (err != 0 && err != -EWOULDBLOCK) + if (err != 0 && err != -EWOULDBLOCK && err != -EAGAIN) { __set_errno (-err); err = -1; @@ -113,7 +113,7 @@ __old_sem_wait (sem_t *sem) /* Disable asynchronous cancellation. */ __pthread_disable_asynccancel (oldtype); } - while (err == 0 || err == -EWOULDBLOCK); + while (err == 0 || err == -EWOULDBLOCK || err == -EAGAIN); __set_errno (-err); return -1; diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c index 6ffa5f25900..b6638bb8e8a 100644 --- a/sunrpc/clnt_udp.c +++ b/sunrpc/clnt_udp.c @@ -463,7 +463,7 @@ send_again: while (inlen < 0 && errno == EINTR); if (inlen < 0) { - if (errno == EWOULDBLOCK) + if (errno == EWOULDBLOCK || errno == EAGAIN) continue; cu->cu_error.re_errno = errno; return (cu->cu_error.re_status = RPC_CANTRECV); diff --git a/sysdeps/nptl/aio_misc.h b/sysdeps/nptl/aio_misc.h index c3de84b1ace..a419ee041f3 100644 --- a/sysdeps/nptl/aio_misc.h +++ b/sysdeps/nptl/aio_misc.h @@ -50,7 +50,7 @@ { \ status = lll_futex_timed_wait (futexaddr, oldval, timeout, \ LLL_PRIVATE); \ - if (status != -EWOULDBLOCK) \ + if (status != -EWOULDBLOCK && status != -EAGAIN) \ break; \ \ oldval = *futexaddr; \ @@ -65,7 +65,7 @@ else if (status == -ETIMEDOUT) \ result = EAGAIN; \ else \ - assert (status == 0 || status == -EWOULDBLOCK); \ + assert (status == 0 || status == -EWOULDBLOCK || status == -EAGAIN);\ \ pthread_mutex_lock (&__aio_requests_mutex); \ } \ diff --git a/sysdeps/nptl/gai_misc.h b/sysdeps/nptl/gai_misc.h index 942f2b1b7e9..fc66256e300 100644 --- a/sysdeps/nptl/gai_misc.h +++ b/sysdeps/nptl/gai_misc.h @@ -51,7 +51,7 @@ { \ status = lll_futex_timed_wait (futexaddr, oldval, timeout, \ LLL_PRIVATE); \ - if (status != -EWOULDBLOCK) \ + if (status != -EWOULDBLOCK && status != -EAGAIN) \ break; \ \ oldval = *futexaddr; \ @@ -66,7 +66,7 @@ else if (status == -ETIMEDOUT) \ result = EAGAIN; \ else \ - assert (status == 0 || status == -EWOULDBLOCK); \ + assert (status == 0 || status == -EWOULDBLOCK || status == -EAGAIN);\ \ pthread_mutex_lock (&__gai_requests_mutex); \ } \ -- 2.47.2