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( ...@@ -1439,10 +1439,9 @@ buf_page_encrypt_before_write(
NOTE! The definition appears here only for other modules of this NOTE! The definition appears here only for other modules of this
directory (buf) to see it. Do not use from outside! */ directory (buf) to see it. Do not use from outside! */
typedef struct { class buf_tmp_buffer_t {
private: /** whether this slot is reserved */
int32 reserved; /*!< true if this slot is reserved std::atomic<bool> reserved;
*/
public: public:
byte* crypt_buf; /*!< for encryption the data needs to be byte* crypt_buf; /*!< for encryption the data needs to be
copied to a separate buffer before it's copied to a separate buffer before it's
...@@ -1458,18 +1457,16 @@ typedef struct { ...@@ -1458,18 +1457,16 @@ typedef struct {
/** Release the slot */ /** Release the slot */
void release() void release()
{ {
my_atomic_store32_explicit(&reserved, false, reserved.store(false, std::memory_order_relaxed);
MY_MEMORY_ORDER_RELAXED);
} }
/** Acquire the slot /** Acquire the slot
@return whether the slot was acquired */ @return whether the slot was acquired */
bool acquire() bool acquire()
{ {
return !my_atomic_fas32_explicit(&reserved, true, return !reserved.exchange(true, std::memory_order_relaxed);
MY_MEMORY_ORDER_RELAXED);
} }
} buf_tmp_buffer_t; };
/** The common buffer control block structure /** The common buffer control block structure
for compressed and uncompressed frames */ 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