this adds another release/acquire link between update_qp and
get_hold_current_qp via the reader_idx because the current
one which is based on the qp users count is only preventing
a race condition, but does not help when the reader acquires
the next qp.
Fixes #27267
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28585)
(cherry picked from commit
d296f9653345d79ee316c053f63a489f001565a5)
/* if the idx hasn't changed, we're good, else try again */
if (qp_idx == ATOMIC_LOAD_N(uint32_t, &lock->reader_idx,
- __ATOMIC_RELAXED))
+ __ATOMIC_ACQUIRE))
break;
ATOMIC_SUB_FETCH(&lock->qp_group[qp_idx].users, (uint64_t)1,
*curr_id = lock->id_ctr;
lock->id_ctr++;
+ /*
+ * make the current state of everything visible by this release
+ * when get_hold_current_qp acquires the next qp
+ */
ATOMIC_STORE_N(uint32_t, &lock->reader_idx, lock->current_alloc_idx,
- __ATOMIC_RELAXED);
+ __ATOMIC_RELEASE);
/*
* this should make sure that the new value of reader_idx is visible in