Commit e976c7db authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-17441 - InnoDB transition to C++11 atomics

Trivial buf_tmp_buffer_t::reserved transition.

Relaxed memory order looks suspicious when used by methods that have
acquire()/release() names. Especially if intention is to transfer some
variable or memory region from one thread to another. Or is memory
ordering guaranteed by something else, e.g. some mutex that protects
broader range of acquire/release functionality?
parent 6a150e26
......@@ -1439,10 +1439,9 @@ buf_page_encrypt_before_write(
NOTE! The definition appears here only for other modules of this
directory (buf) to see it. Do not use from outside! */
typedef struct {
private:
int32 reserved; /*!< true if this slot is reserved
*/
class buf_tmp_buffer_t {
/** whether this slot is reserved */
std::atomic<bool> reserved;
public:
byte* crypt_buf; /*!< for encryption the data needs to be
copied to a separate buffer before it's
......@@ -1458,18 +1457,16 @@ typedef struct {
/** Release the slot */
void release()
{
my_atomic_store32_explicit(&reserved, false,
MY_MEMORY_ORDER_RELAXED);
reserved.store(false, std::memory_order_relaxed);
}
/** Acquire the slot
@return whether the slot was acquired */
bool acquire()
{
return !my_atomic_fas32_explicit(&reserved, true,
MY_MEMORY_ORDER_RELAXED);
return !reserved.exchange(true, std::memory_order_relaxed);
}
} buf_tmp_buffer_t;
};
/** The common buffer control block structure
for compressed and uncompressed frames */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment