mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Fixup the atomic code in pthread_rwlock branch of lib/isc/rwlock.c
This commit is contained in:
parent
48f16f223c
commit
1e2f40d01b
1 changed files with 6 additions and 5 deletions
|
|
@ -53,10 +53,10 @@ isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
|||
while (true) {
|
||||
REQUIRE(pthread_rwlock_wrlock(&rwl->rwlock) == 0);
|
||||
/* Unlock if in middle of downgrade operation */
|
||||
if (atomic_load_release(&rwl->downgrade)) {
|
||||
if (atomic_load_acquire(&rwl->downgrade)) {
|
||||
REQUIRE(pthread_rwlock_unlock(&rwl->rwlock)
|
||||
== 0);
|
||||
while (atomic_load(&rwl->downgrade));
|
||||
while (atomic_load_acquire(&rwl->downgrade));
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
|
@ -78,7 +78,7 @@ isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
|||
break;
|
||||
case isc_rwlocktype_write:
|
||||
ret = pthread_rwlock_trywrlock(&rwl->rwlock);
|
||||
if ((ret == 0) && atomic_load(&rwl->downgrade)) {
|
||||
if ((ret == 0) && atomic_load_acquire(&rwl->downgrade)) {
|
||||
isc_rwlock_unlock(rwl, type);
|
||||
return (ISC_R_LOCKBUSY);
|
||||
}
|
||||
|
|
@ -104,15 +104,16 @@ isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
|||
|
||||
isc_result_t
|
||||
isc_rwlock_tryupgrade(isc_rwlock_t *rwl) {
|
||||
UNUSED(rwl);
|
||||
return (ISC_R_LOCKBUSY);
|
||||
}
|
||||
|
||||
void
|
||||
isc_rwlock_downgrade(isc_rwlock_t *rwl) {
|
||||
atomic_store_acquire(&rwl->downgrade, true);
|
||||
atomic_store_release(&rwl->downgrade, true);
|
||||
isc_rwlock_unlock(rwl, isc_rwlocktype_write);
|
||||
isc_rwlock_lock(rwl, isc_rwlocktype_read);
|
||||
atomic_store_acquire(&rwl->downgrade, false);
|
||||
atomic_store_release(&rwl->downgrade, false);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Reference in a new issue