Commit 00e533c7 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Fixed Mroonga to follow THD ha_data protocol

Use thd_get_ha_data()/thd_set_ha_data() which protect against plugin
removal until it has THD ha_data.

Do not reset THD ha_data in mrn_close_connection(), cleaner approach
is to let ha_close_connection() do it.

Part of MDEV-19515 - Improve connect speed
parent 5c18ba6c
......@@ -1377,11 +1377,10 @@ static void mrn_drop_database(handlerton *hton, char *path)
static int mrn_close_connection(handlerton *hton, THD *thd)
{
MRN_DBUG_ENTER_FUNCTION();
void *p = *thd_ha_data(thd, mrn_hton_ptr);
void *p = thd_get_ha_data(thd, mrn_hton_ptr);
if (p) {
mrn_clear_slot_data(thd);
free(p);
*thd_ha_data(thd, mrn_hton_ptr) = (void *) NULL;
{
mrn::Lock lock(&mrn_allocated_thds_mutex);
my_hash_delete(&mrn_allocated_thds, (uchar*) thd);
......@@ -2040,7 +2039,7 @@ static int mrn_deinit(void *p)
mrn_clear_slot_data(tmp_thd);
void *slot_ptr = mrn_get_slot_data(tmp_thd, false);
if (slot_ptr) free(slot_ptr);
*thd_ha_data(tmp_thd, mrn_hton_ptr) = (void *) NULL;
thd_set_ha_data(tmp_thd, mrn_hton_ptr, 0);
my_hash_delete(&mrn_allocated_thds, (uchar *) tmp_thd);
}
}
......
......@@ -1140,7 +1140,7 @@ st_mrn_slot_data *mrn_get_slot_data(THD *thd, bool can_create)
{
MRN_DBUG_ENTER_FUNCTION();
st_mrn_slot_data *slot_data =
(st_mrn_slot_data*) *thd_ha_data(thd, mrn_hton_ptr);
(st_mrn_slot_data*) thd_get_ha_data(thd, mrn_hton_ptr);
if (slot_data == NULL) {
slot_data = (st_mrn_slot_data*) malloc(sizeof(st_mrn_slot_data));
slot_data->last_insert_record_id = GRN_ID_NIL;
......@@ -1149,7 +1149,7 @@ st_mrn_slot_data *mrn_get_slot_data(THD *thd, bool can_create)
slot_data->disable_keys_create_info = NULL;
slot_data->alter_connect_string = NULL;
slot_data->alter_comment = NULL;
*thd_ha_data(thd, mrn_hton_ptr) = (void *) slot_data;
thd_set_ha_data(thd, mrn_hton_ptr, slot_data);
{
mrn::Lock lock(&mrn_allocated_thds_mutex);
if (my_hash_insert(&mrn_allocated_thds, (uchar*) thd))
......
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