aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2026-01-18 12:23:14 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2026-01-19 16:49:51 +0000
commitce16be73707eedc798b26e0741dcd70d1168ac10 (patch)
treee80991a9c13483e63e58ba0a5e9cabc3f461c23d
parent002c50ea23b99b415b1b392d3dd5ea6223c3a74c (diff)
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
-rw-r--r--lib/libthr/thread/thr_join.c21
1 files 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;