summaryrefslogtreecommitdiff
path: root/storage/myisam/mi_dbug.c
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2010-06-07 16:05:34 +0400
committerKonstantin Osipov <kostja@sun.com>2010-06-07 16:05:34 +0400
commitcc90cbbe60a583a881fba51f09116466fd31b8c2 (patch)
treeadda2a715acd66141cb2dc3ec1ca3980150f4b8d /storage/myisam/mi_dbug.c
parent9dbd9ce185970a45cab0cd8f0a461c9ed6003380 (diff)
downloadmariadb-git-cc90cbbe60a583a881fba51f09116466fd31b8c2.tar.gz
A fix for Bug#52432 "Crash in check_table_is_closed on an
information_schema query. Porting a fix done for a feature tree by Ingo Struewing. No test case since the crash only occurs under a stress load. storage/myisam/mi_dbug.c: Iterate over the list of MyISAM shares and access the MyISAM share internals under a lock.
Diffstat (limited to 'storage/myisam/mi_dbug.c')
-rw-r--r--storage/myisam/mi_dbug.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/storage/myisam/mi_dbug.c b/storage/myisam/mi_dbug.c
index 45882eda6af..e450e81cecb 100644
--- a/storage/myisam/mi_dbug.c
+++ b/storage/myisam/mi_dbug.c
@@ -164,7 +164,19 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg,
} /* print_key */
-#ifdef EXTRA_DEBUG
+#ifdef EXTRA_DEBUG
+/**
+ Check if the named table is in the open list.
+
+ @param[in] name table path as in MYISAM_SHARE::unique_file_name
+ @param[in] where verbal description of caller
+
+ @retval TRUE table is in open list
+ @retval FALSE table is not in open list
+
+ @note This function takes THR_LOCK_myisam. Do not call it when
+ this mutex is locked by this thread already.
+*/
my_bool check_table_is_closed(const char *name, const char *where)
{
@@ -173,6 +185,7 @@ my_bool check_table_is_closed(const char *name, const char *where)
DBUG_ENTER("check_table_is_closed");
(void) fn_format(filename,name,"",MI_NAME_IEXT,4+16+32);
+ mysql_mutex_lock(&THR_LOCK_myisam);
for (pos=myisam_open_list ; pos ; pos=pos->next)
{
MI_INFO *info=(MI_INFO*) pos->data;
@@ -181,12 +194,14 @@ my_bool check_table_is_closed(const char *name, const char *where)
{
if (share->last_version)
{
+ mysql_mutex_unlock(&THR_LOCK_myisam);
fprintf(stderr,"Warning: Table: %s is open on %s\n", name,where);
DBUG_PRINT("warning",("Table: %s is open on %s", name,where));
DBUG_RETURN(1);
}
}
}
+ mysql_mutex_unlock(&THR_LOCK_myisam);
DBUG_RETURN(0);
}
#endif /* EXTRA_DEBUG */