Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Jul 2023 11:45:29 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: b1be52209c42 - stable/13 - libthr: trigger library initialization on rwlock calls
Message-ID:  <202307231145.36NBjTHK096131@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=b1be52209c4237140d0755e1d7d3263ffc3543d2

commit b1be52209c4237140d0755e1d7d3263ffc3543d2
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-07-13 15:56:11 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-07-23 11:44:24 +0000

    libthr: trigger library initialization on rwlock calls
    
    (cherry picked from commit ad056b5d35d9957b1bd023abeb6461601449b725)
---
 lib/libthr/thread/thr_rwlock.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c
index ab10431b9d41..a61eb35cbd31 100644
--- a/lib/libthr/thread/thr_rwlock.c
+++ b/lib/libthr/thread/thr_rwlock.c
@@ -163,6 +163,7 @@ int
 _thr_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
 {
 
+	_thr_check_init();
 	*rwlock = NULL;
 	return (rwlock_init(rwlock, attr));
 }
@@ -231,6 +232,7 @@ rwlock_rdlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime)
 int
 _Tthr_rwlock_rdlock(pthread_rwlock_t *rwlock)
 {
+	_thr_check_init();
 	return (rwlock_rdlock_common(rwlock, NULL));
 }
 
@@ -238,21 +240,24 @@ int
 _pthread_rwlock_timedrdlock(pthread_rwlock_t * __restrict rwlock,
     const struct timespec * __restrict abstime)
 {
+	_thr_check_init();
 	return (rwlock_rdlock_common(rwlock, abstime));
 }
 
 int
 _Tthr_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
 {
-	struct pthread *curthread = _get_curthread();
+	struct pthread *curthread;
 	pthread_rwlock_t prwlock;
 	int flags;
 	int ret;
 
+	_thr_check_init();
 	ret = check_and_init_rwlock(rwlock, &prwlock);
 	if (ret != 0)
 		return (ret);
 
+	curthread = _get_curthread();
 	if (curthread->rdlock_count) {
 		/*
 		 * To avoid having to track all the rdlocks held by
@@ -280,14 +285,16 @@ _Tthr_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
 int
 _Tthr_rwlock_trywrlock(pthread_rwlock_t *rwlock)
 {
-	struct pthread *curthread = _get_curthread();
+	struct pthread *curthread;
 	pthread_rwlock_t prwlock;
 	int ret;
 
+	_thr_check_init();
 	ret = check_and_init_rwlock(rwlock, &prwlock);
 	if (ret != 0)
 		return (ret);
 
+	curthread = _get_curthread();
 	ret = _thr_rwlock_trywrlock(&prwlock->lock);
 	if (ret == 0)
 		prwlock->owner = TID(curthread);
@@ -343,6 +350,7 @@ rwlock_wrlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime)
 int
 _Tthr_rwlock_wrlock(pthread_rwlock_t *rwlock)
 {
+	_thr_check_init();
 	return (rwlock_wrlock_common(rwlock, NULL));
 }
 
@@ -350,6 +358,7 @@ int
 _pthread_rwlock_timedwrlock(pthread_rwlock_t * __restrict rwlock,
     const struct timespec * __restrict abstime)
 {
+	_thr_check_init();
 	return (rwlock_wrlock_common(rwlock, abstime));
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307231145.36NBjTHK096131>