summaryrefslogtreecommitdiff
path: root/sql/examples
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2005-02-12 19:17:33 +0100
committerunknown <guilhem@mysql.com>2005-02-12 19:17:33 +0100
commita8b9f30eb3e5f68a49c6db4476c0ef759ca52157 (patch)
treed0fda1fc6c9183e04fcc6955cd71206f71b9e471 /sql/examples
parent2d619d7cadf45348614884d4cde7ded316e47412 (diff)
downloadmariadb-git-a8b9f30eb3e5f68a49c6db4476c0ef759ca52157.tar.gz
new static archive_inited variable, so that archive_db_end() will do something only if archive_db_init() was run before
(protection against destroying uninited mutex in the case where mysqld fails early at startup (before archive_db_init() was called) and then calls archive_db_end() to clean up). sql/examples/ha_archive.cc: new static archive_inited variable, so that archive_db_end() will do something only if archive_db_init() was run before.
Diffstat (limited to 'sql/examples')
-rw-r--r--sql/examples/ha_archive.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc
index 491056d0e59..bc4af0c7dc7 100644
--- a/sql/examples/ha_archive.cc
+++ b/sql/examples/ha_archive.cc
@@ -114,6 +114,8 @@
data - The data is stored in a "row +blobs" format.
*/
+/* If the archive storage engine has been inited */
+static bool archive_inited= 0;
/* Variables for archive share methods */
pthread_mutex_t archive_mutex;
static HASH archive_open_tables;
@@ -157,6 +159,7 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length,
bool archive_db_init()
{
+ archive_inited= 1;
VOID(pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST));
return (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
(hash_get_key) archive_get_key, 0, 0));
@@ -176,8 +179,12 @@ bool archive_db_init()
bool archive_db_end()
{
- hash_free(&archive_open_tables);
- VOID(pthread_mutex_destroy(&archive_mutex));
+ if (archive_inited)
+ {
+ hash_free(&archive_open_tables);
+ VOID(pthread_mutex_destroy(&archive_mutex));
+ }
+ archive_inited= 0;
return FALSE;
}