]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
aio_suspend64: Fix clock discrepancy [BZ #32795]
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 9 Mar 2025 21:25:14 +0000 (22:25 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Tue, 25 Mar 2025 00:05:11 +0000 (01:05 +0100)
cc5d5852c65e ("y2038: Convert aio_suspend to support 64 bit time")
switched from __clock_gettime (CLOCK_REALTIME, &now); to __clock_gettime64
(CLOCK_MONOTONIC, &ts);, but pthread_cond_timedwait is based on the
absolute realtime clock, so migrate to using pthread_cond_clockwait to
select CLOCK_MONOTONIC. Also fix AIO_MISC_WAIT into passing
CLOCK_MONOTONIC to __futex_abstimed_wait64.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
rt/aio_suspend.c
sysdeps/nptl/aio_misc.h

index 2257cd80d493c5f7a2e55d8eeb326d406ccce97e..05000293008640677e9de33def386266a8c8f8b7 100644 (file)
@@ -195,8 +195,9 @@ ___aio_suspend_time64 (const struct aiocb *const list[], int nent,
       result = do_aio_misc_wait (&cntr, timeout == NULL ? NULL : &ts);
 #else
       struct timespec ts32 = valid_timespec64_to_timespec (ts);
-      result = pthread_cond_timedwait (&cond, &__aio_requests_mutex,
-                                      timeout == NULL ? NULL : &ts32);
+      result = __pthread_cond_clockwait (&cond, &__aio_requests_mutex,
+                                        CLOCK_MONOTONIC,
+                                        timeout == NULL ? NULL : &ts32);
 #endif
 
 #if PTHREAD_IN_LIBC
index ddc5acc37933fe94c6f18e1a9b1210e20249e40c..87fd759f13542f009d1bf1c188208bf3db49dea6 100644 (file)
@@ -50,7 +50,7 @@
                FUTEX_PRIVATE);                                               \
            else                                                              \
              status = __futex_abstimed_wait64 ((unsigned int *) futexaddr,   \
-               oldval, CLOCK_REALTIME, timeout, FUTEX_PRIVATE);              \
+               oldval, CLOCK_MONOTONIC, timeout, FUTEX_PRIVATE);             \
            if (status != EAGAIN)                                             \
              break;                                                          \
                                                                              \