diff options
-rw-r--r-- | storage/tokudb/ha_tokudb.cc | 12 | ||||
-rw-r--r-- | storage/tokudb/ha_tokudb.h | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc index 4637ac1bf5f..34a7fefde30 100644 --- a/storage/tokudb/ha_tokudb.cc +++ b/storage/tokudb/ha_tokudb.cc @@ -48,7 +48,7 @@ static inline uint get_ext_key_parts(const KEY *key) { #endif // defined(TOKU_INCLUDE_EXTENDED_KEYS) && TOKU_INCLUDE_EXTENDED_KEYS std::unordered_map<std::string, TOKUDB_SHARE*> TOKUDB_SHARE::_open_tables; -tokudb::thread::mutex_t TOKUDB_SHARE::_open_tables_mutex; +tokudb::thread::mutex_t* TOKUDB_SHARE::_open_tables_mutex; static const char* ha_tokudb_exts[] = { ha_tokudb_ext, @@ -154,6 +154,7 @@ static void free_key_and_col_info (KEY_AND_COL_INFO* kc_info) { void TOKUDB_SHARE::static_init() { assert_always(_open_tables.size() == 0); + _open_tables_mutex = new tokudb::thread::mutex_t(); } void TOKUDB_SHARE::static_destroy() { for (auto it = _open_tables.cbegin(); it != _open_tables.cend(); it++) { @@ -164,6 +165,7 @@ void TOKUDB_SHARE::static_destroy() { } _open_tables.clear(); assert_always(_open_tables.size() == 0); + delete _open_tables_mutex; } const char* TOKUDB_SHARE::get_state_string(share_state_t state) { static const char* state_string[] = { @@ -218,7 +220,7 @@ TOKUDB_SHARE* TOKUDB_SHARE::get_share(const char* table_name, THR_LOCK_DATA* data, bool create_new) { std::string find_table_name(table_name); - mutex_t_lock(_open_tables_mutex); + mutex_t_lock(*_open_tables_mutex); auto it = _open_tables.find(find_table_name); TOKUDB_SHARE *share = nullptr; if (it != _open_tables.end()) { @@ -251,7 +253,7 @@ TOKUDB_SHARE* TOKUDB_SHARE::get_share(const char* table_name, thr_lock_data_init(&(share->_thr_lock), data, NULL); exit: - mutex_t_unlock(_open_tables_mutex); + mutex_t_unlock(*_open_tables_mutex); return share; } void TOKUDB_SHARE::drop_share(TOKUDB_SHARE* share) { @@ -262,12 +264,12 @@ void TOKUDB_SHARE::drop_share(TOKUDB_SHARE* share) { get_state_string(share->_state), share->_use_count); - mutex_t_lock(_open_tables_mutex); + mutex_t_lock(*_open_tables_mutex); size_t n = _open_tables.erase(std::string(share->full_table_name())); assert_always(n == 1); share->destroy(); delete share; - mutex_t_unlock(_open_tables_mutex); + mutex_t_unlock(*_open_tables_mutex); } TOKUDB_SHARE::share_state_t TOKUDB_SHARE::addref() { TOKUDB_SHARE_TRACE_FOR_FLAGS((TOKUDB_DEBUG_ENTER & TOKUDB_DEBUG_SHARE), diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h index 6f592617b76..e322c3de18e 100644 --- a/storage/tokudb/ha_tokudb.h +++ b/storage/tokudb/ha_tokudb.h @@ -274,7 +274,7 @@ public: private: static std::unordered_map<std::string, TOKUDB_SHARE*> _open_tables; - static tokudb::thread::mutex_t _open_tables_mutex; + static tokudb::thread::mutex_t* _open_tables_mutex; //********************************* // Spans open-close-open |