The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ce16be73707eedc798b26e0741dcd70d1168ac10
commit ce16be73707eedc798b26e0741dcd70d1168ac10 Author: Konstantin Belousov <[email protected]> AuthorDate: 2026-01-18 12:23:14 +0000 Commit: Konstantin Belousov <[email protected]> CommitDate: 2026-01-19 16:49:51 +0000 libthr/thread/thr_join.c: deduplicate backout_join() helper Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54766 --- lib/libthr/thread/thr_join.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/libthr/thread/thr_join.c b/lib/libthr/thread/thr_join.c index 53f28daa258d..56b316ec0f51 100644 --- a/lib/libthr/thread/thr_join.c +++ b/lib/libthr/thread/thr_join.c @@ -43,16 +43,23 @@ __weak_reference(_thr_join, _pthread_join); __weak_reference(_pthread_timedjoin_np, pthread_timedjoin_np); __weak_reference(_pthread_peekjoin_np, pthread_peekjoin_np); -static void backout_join(void *arg) +static void +backout_join(struct pthread *pthread, struct pthread *curthread) { - struct pthread *pthread = (struct pthread *)arg; - struct pthread *curthread = _get_curthread(); - THR_THREAD_LOCK(curthread, pthread); pthread->joiner = NULL; THR_THREAD_UNLOCK(curthread, pthread); } +static void +backout_join_pop(void *arg) +{ + struct pthread *pthread = (struct pthread *)arg; + struct pthread *curthread = _get_curthread(); + + backout_join(pthread, curthread); +} + int _thr_join(pthread_t pthread, void **thread_return) { @@ -149,10 +156,8 @@ join_common(pthread_t pthread, void **thread_return, _thr_cancel_leave(curthread, 0); THR_CLEANUP_POP(curthread, 0); - if (ret == ETIMEDOUT) { - THR_THREAD_LOCK(curthread, pthread); - pthread->joiner = NULL; - THR_THREAD_UNLOCK(curthread, pthread); + if (ret == ETIMEDOUT || ret == EBUSY) { + backout_join(pthread, curthread); } else { ret = 0; tmp = pthread->ret;
