Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178089356
D60960.1795927837.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D60960.1795927837.diff
View Options
diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c
--- a/lib/libthr/thread/thr_rwlock.c
+++ b/lib/libthr/thread/thr_rwlock.c
@@ -132,6 +132,12 @@
__thr_pshared_destroy(rwlock);
ret = 0;
} else {
+ int32_t state;
+
+ state = prwlock->lock.rw_state;
+ if ((state & URWLOCK_WRITE_OWNER) != 0 ||
+ URWLOCK_READER_COUNT(state) != 0)
+ return (EBUSY);
*rwlock = THR_RWLOCK_DESTROYED;
free(prwlock);
ret = 0;
diff --git a/share/man/man3/pthread_rwlock_destroy.3 b/share/man/man3/pthread_rwlock_destroy.3
--- a/share/man/man3/pthread_rwlock_destroy.3
+++ b/share/man/man3/pthread_rwlock_destroy.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 4, 1998
+.Dd October 21, 2026
.Dt PTHREAD_RWLOCK_DESTROY 3
.Os
.Sh NAME
@@ -39,6 +39,15 @@
.Fn pthread_rwlock_destroy
function is used to destroy a read/write lock previously created with
.Fn pthread_rwlock_init .
+.Pp
+The results are undefined if
+.Fn pthread_rwlock_destroy
+is called while the lock is held by any thread, or while any thread is
+blocked waiting to acquire it.
+Such an attempt may be reported as
+.Er EBUSY ,
+but the detection is advisory: it is not attempted for process-shared
+locks, and callers must not depend on it.
.Sh RETURN VALUES
If successful, the
.Fn pthread_rwlock_destroy
@@ -48,14 +57,6 @@
.Sh ERRORS
The
.Fn pthread_rwlock_destroy
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The caller does not have the privilege to perform the operation.
-.El
-.Pp
-The
-.Fn pthread_rwlock_destroy
function may fail if:
.Bl -tag -width Er
.It Bq Er EBUSY
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 29, 4:50 AM (51 m, 28 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42084190
Default Alt Text
D60960.1795927837.diff (1 KB)
Attached To
Mode
D60960: libthr: Robust rwlock destory
Attached
Detach File
Event Timeline