Skip to content

Commit e976c7d

Browse files
committed
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?
1 parent 6a150e2 commit e976c7d

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

storage/innobase/include/buf0buf.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,10 +1439,9 @@ buf_page_encrypt_before_write(
14391439
NOTE! The definition appears here only for other modules of this
14401440
directory (buf) to see it. Do not use from outside! */
14411441

1442-
typedef struct {
1443-
private:
1444-
int32 reserved; /*!< true if this slot is reserved
1445-
*/
1442+
class buf_tmp_buffer_t {
1443+
/** whether this slot is reserved */
1444+
std::atomic<bool> reserved;
14461445
public:
14471446
byte* crypt_buf; /*!< for encryption the data needs to be
14481447
copied to a separate buffer before it's
@@ -1458,18 +1457,16 @@ typedef struct {
14581457
/** Release the slot */
14591458
void release()
14601459
{
1461-
my_atomic_store32_explicit(&reserved, false,
1462-
MY_MEMORY_ORDER_RELAXED);
1460+
reserved.store(false, std::memory_order_relaxed);
14631461
}
14641462

14651463
/** Acquire the slot
14661464
@return whether the slot was acquired */
14671465
bool acquire()
14681466
{
1469-
return !my_atomic_fas32_explicit(&reserved, true,
1470-
MY_MEMORY_ORDER_RELAXED);
1467+
return !reserved.exchange(true, std::memory_order_relaxed);
14711468
}
1472-
} buf_tmp_buffer_t;
1469+
};
14731470

14741471
/** The common buffer control block structure
14751472
for compressed and uncompressed frames */

0 commit comments

Comments
 (0)