mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 05:00:00 -04:00
Unify the int32_t vs int_fast32_t when working with atomic types
There's a mismatch between the atomic and non-atomic types that could potentialy lead to a rwlock deadlock (after two billion 2^32) writes. Use int_fast32_t when loading the atomic_int_fast32_t types in the isc_rwlock unit.
This commit is contained in:
parent
74e28cc4be
commit
86673ee67a
1 changed files with 8 additions and 8 deletions
|
|
@ -305,7 +305,7 @@ isc_rwlock_destroy(isc_rwlock_t *rwl) {
|
|||
|
||||
static isc_result_t
|
||||
isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
||||
int32_t cntflag;
|
||||
int_fast32_t cntflag;
|
||||
|
||||
REQUIRE(VALID_RWLOCK(rwl));
|
||||
|
||||
|
|
@ -383,7 +383,7 @@ isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
|||
*/
|
||||
atomic_store_release(&rwl->write_granted, 0);
|
||||
} else {
|
||||
int32_t prev_writer;
|
||||
int_fast32_t prev_writer;
|
||||
|
||||
/* enter the waiting queue, and wait for our turn */
|
||||
prev_writer = atomic_fetch_add_release(&rwl->write_requests, 1);
|
||||
|
|
@ -427,9 +427,9 @@ isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
|||
|
||||
isc_result_t
|
||||
isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
||||
int32_t cnt = 0;
|
||||
int32_t spins = atomic_load_acquire(&rwl->spins) * 2 + 10;
|
||||
int32_t max_cnt = ISC_MAX(spins, RWLOCK_MAX_ADAPTIVE_COUNT);
|
||||
int_fast32_t cnt = 0;
|
||||
int_fast32_t spins = atomic_load_acquire(&rwl->spins) * 2 + 10;
|
||||
int_fast32_t max_cnt = ISC_MAX(spins, RWLOCK_MAX_ADAPTIVE_COUNT);
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
do {
|
||||
|
|
@ -447,7 +447,7 @@ isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
|||
|
||||
isc_result_t
|
||||
isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
||||
int32_t cntflag;
|
||||
int_fast32_t cntflag;
|
||||
|
||||
REQUIRE(VALID_RWLOCK(rwl));
|
||||
|
||||
|
|
@ -544,7 +544,7 @@ isc_rwlock_tryupgrade(isc_rwlock_t *rwl) {
|
|||
|
||||
void
|
||||
isc_rwlock_downgrade(isc_rwlock_t *rwl) {
|
||||
int32_t prev_readers;
|
||||
int_fast32_t prev_readers;
|
||||
|
||||
REQUIRE(VALID_RWLOCK(rwl));
|
||||
|
||||
|
|
@ -568,7 +568,7 @@ isc_rwlock_downgrade(isc_rwlock_t *rwl) {
|
|||
|
||||
isc_result_t
|
||||
isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
||||
int32_t prev_cnt;
|
||||
int_fast32_t prev_cnt;
|
||||
|
||||
REQUIRE(VALID_RWLOCK(rwl));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue