Commit 891b06eb authored by marko's avatar marko

branches/zip: Initialize ut_list_mutex at startup. Without this fix,

ut_list_mutex would be used uninitialized when innodb_use_sys_malloc=1.
This fix addresses Issue #181.

ut_mem_block_list_init(): Rename to ut_mem_init() and make public.

ut_malloc_low(), ut_free_all_mem(): Add ut_a(ut_mem_block_list_inited).

mem_init(): Call ut_mem_init().
parent d15afc73
...@@ -49,6 +49,12 @@ UNIV_INLINE ...@@ -49,6 +49,12 @@ UNIV_INLINE
int int
ut_memcmp(const void* str1, const void* str2, ulint n); ut_memcmp(const void* str1, const void* str2, ulint n);
/**************************************************************************
Initializes the mem block list at database startup. */
UNIV_INTERN
void
ut_mem_init(void);
/*=============*/
/************************************************************************** /**************************************************************************
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
......
...@@ -163,6 +163,8 @@ mem_init( ...@@ -163,6 +163,8 @@ mem_init(
} }
mem_comm_pool = mem_pool_create(size); mem_comm_pool = mem_pool_create(size);
ut_mem_init();
} }
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
......
...@@ -64,10 +64,10 @@ static ulint* ut_mem_null_ptr = NULL; ...@@ -64,10 +64,10 @@ static ulint* ut_mem_null_ptr = NULL;
/************************************************************************** /**************************************************************************
Initializes the mem block list at database startup. */ Initializes the mem block list at database startup. */
static UNIV_INTERN
void void
ut_mem_block_list_init(void) ut_mem_init(void)
/*========================*/ /*=============*/
{ {
os_fast_mutex_init(&ut_list_mutex); os_fast_mutex_init(&ut_list_mutex);
UT_LIST_INIT(ut_mem_block_list); UT_LIST_INIT(ut_mem_block_list);
...@@ -106,10 +106,7 @@ ut_malloc_low( ...@@ -106,10 +106,7 @@ ut_malloc_low(
} }
ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */ ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
ut_a(ut_mem_block_list_inited);
if (UNIV_UNLIKELY(!ut_mem_block_list_inited)) {
ut_mem_block_list_init();
}
retry_count = 0; retry_count = 0;
retry: retry:
...@@ -383,10 +380,7 @@ ut_free_all_mem(void) ...@@ -383,10 +380,7 @@ ut_free_all_mem(void)
{ {
ut_mem_block_t* block; ut_mem_block_t* block;
if (!ut_mem_block_list_inited) { ut_a(ut_mem_block_list_inited);
return;
}
ut_mem_block_list_inited = FALSE; ut_mem_block_list_inited = FALSE;
os_fast_mutex_free(&ut_list_mutex); os_fast_mutex_free(&ut_list_mutex);
......
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