Commit b390447e authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-19513: Remove rw_lock_t::magic_n

The magic_n only complicated object destruction and did not serve
any useful purpose.
parent 5fd7502e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc. Copyright (c) 2008, Google Inc.
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved. Copyright (c) 2017, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
...@@ -625,35 +625,14 @@ struct rw_lock_t ...@@ -625,35 +625,14 @@ struct rw_lock_t
#endif /* UNIV_PFS_RWLOCK */ #endif /* UNIV_PFS_RWLOCK */
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/** Value of rw_lock_t::magic_n */
# define RW_LOCK_MAGIC_N 22643
/** Constructor */
rw_lock_t()
{
magic_n = RW_LOCK_MAGIC_N;
}
/** Destructor */
virtual ~rw_lock_t()
{
ut_ad(magic_n == RW_LOCK_MAGIC_N);
magic_n = 0;
}
virtual std::string to_string() const; virtual std::string to_string() const;
/** For checking memory corruption. */
ulint magic_n;
/** In the debug version: pointer to the debug info list of the lock */ /** In the debug version: pointer to the debug info list of the lock */
UT_LIST_BASE_NODE_T(rw_lock_debug_t) debug_list; UT_LIST_BASE_NODE_T(rw_lock_debug_t) debug_list;
/** Level in the global latching order. */ /** Level in the global latching order. */
latch_level_t level; latch_level_t level;
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
}; };
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/** The structure for storing debug info of an rw-lock. All access to this /** The structure for storing debug info of an rw-lock. All access to this
......
...@@ -2011,11 +2011,6 @@ void log_t::close() ...@@ -2011,11 +2011,6 @@ void log_t::close()
os_event_destroy(flush_event); os_event_destroy(flush_event);
rw_lock_free(&checkpoint_lock); rw_lock_free(&checkpoint_lock);
/* rw_lock_free() already called checkpoint_lock.~rw_lock_t();
tame the debug assertions when the destructor will be called once more. */
ut_ad(checkpoint_lock.magic_n == 0);
ut_d(checkpoint_lock.magic_n = RW_LOCK_MAGIC_N);
mutex_free(&mutex); mutex_free(&mutex);
mutex_free(&write_mutex); mutex_free(&write_mutex);
mutex_free(&log_flush_order_mutex); mutex_free(&log_flush_order_mutex);
......
...@@ -238,12 +238,7 @@ rw_lock_create_func( ...@@ -238,12 +238,7 @@ rw_lock_create_func(
lock->is_block_lock = 0; lock->is_block_lock = 0;
mutex_enter(&rw_lock_list_mutex); mutex_enter(&rw_lock_list_mutex);
ut_ad(UT_LIST_GET_FIRST(rw_lock_list) == NULL
|| UT_LIST_GET_FIRST(rw_lock_list)->magic_n == RW_LOCK_MAGIC_N);
UT_LIST_ADD_FIRST(rw_lock_list, lock); UT_LIST_ADD_FIRST(rw_lock_list, lock);
mutex_exit(&rw_lock_list_mutex); mutex_exit(&rw_lock_list_mutex);
} }
...@@ -268,12 +263,6 @@ rw_lock_free_func( ...@@ -268,12 +263,6 @@ rw_lock_free_func(
UT_LIST_REMOVE(rw_lock_list, lock); UT_LIST_REMOVE(rw_lock_list, lock);
mutex_exit(&rw_lock_list_mutex); mutex_exit(&rw_lock_list_mutex);
/* We did an in-place new in rw_lock_create_func() */
ut_d(lock->~rw_lock_t());
/* Sometimes (maybe when compiled with GCC -O3) the above call
to rw_lock_t::~rw_lock_t() will not actually assign magic_n=0. */
ut_d(lock->magic_n = 0);
} }
/******************************************************************//** /******************************************************************//**
...@@ -858,7 +847,6 @@ rw_lock_validate( ...@@ -858,7 +847,6 @@ rw_lock_validate(
lock_word = lock->lock_word.load(std::memory_order_relaxed); lock_word = lock->lock_word.load(std::memory_order_relaxed);
ut_ad(lock->magic_n == RW_LOCK_MAGIC_N);
ut_ad(lock->waiters.load(std::memory_order_relaxed) < 2); ut_ad(lock->waiters.load(std::memory_order_relaxed) < 2);
ut_ad(lock_word > -(2 * X_LOCK_DECR)); ut_ad(lock_word > -(2 * X_LOCK_DECR));
ut_ad(lock_word <= X_LOCK_DECR); ut_ad(lock_word <= X_LOCK_DECR);
......
...@@ -192,10 +192,6 @@ void purge_sys_t::close() ...@@ -192,10 +192,6 @@ void purge_sys_t::close()
trx->state= TRX_STATE_NOT_STARTED; trx->state= TRX_STATE_NOT_STARTED;
trx_free(trx); trx_free(trx);
rw_lock_free(&latch); rw_lock_free(&latch);
/* rw_lock_free() already called latch.~rw_lock_t(); tame the
debug assertions when the destructor will be called once more. */
ut_ad(latch.magic_n == 0);
ut_d(latch.magic_n= RW_LOCK_MAGIC_N);
mutex_free(&pq_mutex); mutex_free(&pq_mutex);
os_event_destroy(event); os_event_destroy(event);
} }
......
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