htl: Make pthread_cond_destroy wait for threads to be woken

System Internals / glibc - Samuel Thibault [ens-lyon.org] - 1 June 2020 17:38 UTC

This allows to reuse the storage after calling pthread_cond_destroy.

- sysdeps/htl/bits/types/struct___pthread_cond.h (__pthread_cond): Replace unused struct __pthread_condimpl *__impl field with unsigned int __wrefs. (__PTHREAD_COND_INITIALIZER): Update accordingly.
- sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal): Register as waiter in __wrefs field. On unregistering, wake any pending pthread_cond_destroy.
- sysdeps/htl/pt-cond-destroy.c (__pthread_cond_destroy): Register wake request in __wrefs.
- nptl/Makefile (tests): Move tst-cond20 tst-cond21 to...
- sysdeps/pthread/Makefile (tests): ... here.
- nptl/tst-cond20.c nptl/tst-cond21.c: Move to...
- sysdeps/pthread/tst-cond20.c sysdeps/pthread/tst-cond21.c: ... here.

8081702460 htl: Make pthread_cond_destroy wait for threads to be woken
nptl/Makefile | 2 +-
sysdeps/htl/bits/types/struct___pthread_cond.h | 4 ++--
sysdeps/htl/pt-cond-destroy.c | 18 +++++++++++++++---
sysdeps/htl/pt-cond-timedwait.c | 11 +++++++++++
sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c | 11 +++++++++++
sysdeps/pthread/Makefile | 2 +-
{nptl => sysdeps/pthread}/tst-cond20.c | 0
{nptl => sysdeps/pthread}/tst-cond21.c | 0
8 files changed, 41 insertions(+), 7 deletions(-)

Upstream: sourceware.org


  • Share