]> git.ipfire.org Git - thirdparty/glibc.git/commit
nptl: Fix __futex_clocklock64 return error check [BZ #26964]
authorLucas A. M. Magalhaes <lamm@linux.ibm.com>
Tue, 1 Dec 2020 21:05:07 +0000 (18:05 -0300)
committerTulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Tue, 1 Dec 2020 21:26:26 +0000 (18:26 -0300)
commit61855081017dff30c577855cda882740356b5d98
tree69472c92f3f8b65c240b5987bbeee2760108933b
parent33fc34521de970153344cfe1bfa9ce6da7a6efea
nptl: Fix __futex_clocklock64 return error check [BZ #26964]

The earlier implementation of this, __lll_clocklock, calls lll_clockwait
that doesn't return the futex syscall error codes.  It always tries again
if that fails.

However in the current implementation, when the futex returns EAGAIN,
__futex_clocklock64 will also return EGAIN, even if the futex is taken.

This patch fixes the EAGAIN issue and also adds a check for EINTR.  As
futex syscall can return EINTR if the thread is interrupted by a signal.
In this case I'm assuming the function should continue trying to lock as
there is no mention to about it on POSIX.  Also add a test for both
scenarios.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
nptl/Makefile
nptl/tst-pthread-timedlock-lockloop.c [new file with mode: 0644]
sysdeps/nptl/futex-internal.h