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
This commit is contained in:
Konstantin Belousov
2026-01-18 14:23:14 +02:00
parent 002c50ea23
commit ce16be7370
+13 -8
View File
@@ -43,14 +43,21 @@ __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)
{
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();
THR_THREAD_LOCK(curthread, pthread);
pthread->joiner = NULL;
THR_THREAD_UNLOCK(curthread, pthread);
backout_join(pthread, curthread);
}
int
@@ -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;