Commit 93ec81bb authored by marko's avatar marko

branches/zip: Correct the initialization of the memory subsystem once

again, to finally put Issue #181 to rest.

Revert some parts of r4274.  It is best not to call ut_malloc() before
srv_general_init().

mem_init(): Do not call ut_mem_init().

srv_general_init(): Initialize the memory subsystem in two phases:
first ut_mem_init(), then mem_init().  This is because os_sync_init()
and sync_init() depend on ut_mem_init() and mem_init() depends on
os_sync_init() or sync_init().

srv_parse_data_file_paths_and_sizes(),
srv_parse_log_group_home_dirs(): Remove the output parameters.  Assign
to the global variables directly.  Allocate memory with malloc()
instead of ut_malloc(), because these functions will be called before
srv_general_init().

srv_free_paths_and_sizes(): New function, for cleaning up after
srv_parse_data_file_paths_and_sizes() and
srv_parse_log_group_home_dirs().

rb://92 approved by Sunny Bains
parent 09f6d57a
......@@ -1988,27 +1988,16 @@ innobase_init(
internal_innobase_data_file_path = my_strdup(innobase_data_file_path,
MYF(MY_FAE));
srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
/* Initialize the InnoDB memory subsystem before calling
ut_malloc() in srv_parse_data_file_paths_and_sizes(). */
mem_init(srv_mem_pool_size);
ret = (bool) srv_parse_data_file_paths_and_sizes(
internal_innobase_data_file_path,
&srv_data_file_names,
&srv_data_file_sizes,
&srv_data_file_is_raw_partition,
&srv_n_data_files,
&srv_auto_extend_last_data_file,
&srv_last_file_size_max);
internal_innobase_data_file_path);
if (ret == FALSE) {
sql_print_error(
"InnoDB: syntax error in innodb_data_file_path");
mem_free_and_error:
srv_free_paths_and_sizes();
my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
ut_free_all_mem();
goto error;
}
......@@ -2031,8 +2020,7 @@ mem_free_and_error:
#endif /* UNIG_LOG_ARCHIVE */
ret = (bool)
srv_parse_log_group_home_dirs(innobase_log_group_home_dir,
&srv_log_group_home_dirs);
srv_parse_log_group_home_dirs(innobase_log_group_home_dir);
if (ret == FALSE || innobase_mirrored_log_groups != 1) {
sql_print_error("syntax error in innodb_log_group_home_dir, or a "
......@@ -2113,6 +2101,8 @@ mem_free_and_error:
srv_buf_pool_size = (ulint) innobase_buffer_pool_size;
srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
srv_n_file_io_threads = (ulint) innobase_file_io_threads;
srv_force_recovery = (ulint) innobase_force_recovery;
......@@ -2212,6 +2202,7 @@ innobase_end(handlerton *hton, ha_panic_function type)
if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
err = 1;
}
srv_free_paths_and_sizes();
my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
pthread_mutex_destroy(&innobase_share_mutex);
......
......@@ -356,7 +356,8 @@ void
srv_free(void);
/*==========*/
/*************************************************************************
Initializes the synchronization primitives and the thread local storage. */
Initializes the synchronization primitives, memory system, and the thread
local storage. */
UNIV_INTERN
void
srv_general_init(void);
......
......@@ -42,21 +42,8 @@ UNIV_INTERN
ibool
srv_parse_data_file_paths_and_sizes(
/*================================*/
/* out: TRUE if ok, FALSE if parsing
error */
char* str, /* in: the data file path string */
char*** data_file_names, /* out, own: array of data file
names */
ulint** data_file_sizes, /* out, own: array of data file sizes
in megabytes */
ulint** data_file_is_raw_partition,/* out, own: array of flags
showing which data files are raw
partitions */
ulint* n_data_files, /* out: number of data files */
ibool* is_auto_extending, /* out: TRUE if the last data file is
auto-extending */
ulint* max_auto_extend_size); /* out: max auto extend size for the
last file if specified, 0 if not */
/* out: TRUE if ok, FALSE on parse error */
char* str); /* in/out: the data file path string */
/*************************************************************************
Reads log group home directories from a character string given in
the .cnf file. */
......@@ -64,10 +51,15 @@ UNIV_INTERN
ibool
srv_parse_log_group_home_dirs(
/*==========================*/
/* out: TRUE if ok, FALSE if parsing
error */
char* str, /* in: character string */
char*** log_group_home_dirs); /* out, own: log group home dirs */
/* out: TRUE if ok, FALSE on parse error */
char* str); /* in/out: character string */
/*************************************************************************
Frees the memory allocated by srv_parse_data_file_paths_and_sizes()
and srv_parse_log_group_home_dirs(). */
UNIV_INTERN
void
srv_free_paths_and_sizes(void);
/*==========================*/
/*************************************************************************
Adds a slash or a backslash to the end of a string if it is missing
and the string is not empty. */
......
......@@ -162,7 +162,6 @@ mem_init(
size = 1;
}
ut_mem_init();
mem_comm_pool = mem_pool_create(size);
}
......
......@@ -960,14 +960,17 @@ srv_free(void)
}
/*************************************************************************
Initializes the synchronization primitives and the thread local storage. */
Initializes the synchronization primitives, memory system, and the thread
local storage. */
UNIV_INTERN
void
srv_general_init(void)
/*==================*/
{
ut_mem_init();
os_sync_init();
sync_init();
mem_init(srv_mem_pool_size);
thr_local_init();
}
......
......@@ -174,29 +174,19 @@ UNIV_INTERN
ibool
srv_parse_data_file_paths_and_sizes(
/*================================*/
/* out: TRUE if ok, FALSE if parsing
error */
char* str, /* in: the data file path string */
char*** data_file_names, /* out, own: array of data file
names */
ulint** data_file_sizes, /* out, own: array of data file sizes
in megabytes */
ulint** data_file_is_raw_partition,/* out, own: array of flags
showing which data files are raw
partitions */
ulint* n_data_files, /* out: number of data files */
ibool* is_auto_extending, /* out: TRUE if the last data file is
auto-extending */
ulint* max_auto_extend_size) /* out: max auto extend size for the
last file if specified, 0 if not */
/* out: TRUE if ok, FALSE on parse error */
char* str) /* in/out: the data file path string */
{
char* input_str;
char* path;
ulint size;
ulint i = 0;
*is_auto_extending = FALSE;
*max_auto_extend_size = 0;
srv_auto_extend_last_data_file = FALSE;
srv_last_file_size_max = 0;
srv_data_file_names = NULL;
srv_data_file_sizes = NULL;
srv_data_file_is_raw_partition = NULL;
input_str = str;
......@@ -273,11 +263,12 @@ srv_parse_data_file_paths_and_sizes(
return(FALSE);
}
*data_file_names = (char**)ut_malloc(i * sizeof(void*));
*data_file_sizes = (ulint*)ut_malloc(i * sizeof(ulint));
*data_file_is_raw_partition = (ulint*)ut_malloc(i * sizeof(ulint));
srv_data_file_names = malloc(i * sizeof *srv_data_file_names);
srv_data_file_sizes = malloc(i * sizeof *srv_data_file_sizes);
srv_data_file_is_raw_partition = malloc(
i * sizeof *srv_data_file_is_raw_partition);
*n_data_files = i;
srv_n_data_files = i;
/* Then store the actual values to our arrays */
......@@ -307,13 +298,13 @@ srv_parse_data_file_paths_and_sizes(
str = srv_parse_megabytes(str, &size);
(*data_file_names)[i] = path;
(*data_file_sizes)[i] = size;
srv_data_file_names[i] = path;
srv_data_file_sizes[i] = size;
if (0 == strncmp(str, ":autoextend",
(sizeof ":autoextend") - 1)) {
*is_auto_extending = TRUE;
srv_auto_extend_last_data_file = TRUE;
str += (sizeof ":autoextend") - 1;
......@@ -323,7 +314,7 @@ srv_parse_data_file_paths_and_sizes(
str += (sizeof ":max:") - 1;
str = srv_parse_megabytes(
str, max_auto_extend_size);
str, &srv_last_file_size_max);
}
if (*str != '\0') {
......@@ -332,21 +323,21 @@ srv_parse_data_file_paths_and_sizes(
}
}
(*data_file_is_raw_partition)[i] = 0;
(srv_data_file_is_raw_partition)[i] = 0;
if (strlen(str) >= 6
&& *str == 'n'
&& *(str + 1) == 'e'
&& *(str + 2) == 'w') {
str += 3;
(*data_file_is_raw_partition)[i] = SRV_NEW_RAW;
(srv_data_file_is_raw_partition)[i] = SRV_NEW_RAW;
}
if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
str += 3;
if ((*data_file_is_raw_partition)[i] == 0) {
(*data_file_is_raw_partition)[i] = SRV_OLD_RAW;
if ((srv_data_file_is_raw_partition)[i] == 0) {
(srv_data_file_is_raw_partition)[i] = SRV_OLD_RAW;
}
}
......@@ -367,15 +358,15 @@ UNIV_INTERN
ibool
srv_parse_log_group_home_dirs(
/*==========================*/
/* out: TRUE if ok, FALSE if parsing
error */
char* str, /* in: character string */
char*** log_group_home_dirs) /* out, own: log group home dirs */
/* out: TRUE if ok, FALSE on parse error */
char* str) /* in/out: character string */
{
char* input_str;
char* path;
ulint i = 0;
srv_log_group_home_dirs = NULL;
input_str = str;
/* First calculate the number of directories and check syntax:
......@@ -405,7 +396,7 @@ srv_parse_log_group_home_dirs(
return(FALSE);
}
*log_group_home_dirs = (char**) ut_malloc(i * sizeof(void*));
srv_log_group_home_dirs = malloc(i * sizeof *srv_log_group_home_dirs);
/* Then store the actual values to our array */
......@@ -424,7 +415,7 @@ srv_parse_log_group_home_dirs(
str++;
}
(*log_group_home_dirs)[i] = path;
srv_log_group_home_dirs[i] = path;
i++;
}
......@@ -432,6 +423,24 @@ srv_parse_log_group_home_dirs(
return(TRUE);
}
/*************************************************************************
Frees the memory allocated by srv_parse_data_file_paths_and_sizes()
and srv_parse_log_group_home_dirs(). */
UNIV_INTERN
void
srv_free_paths_and_sizes(void)
/*==========================*/
{
free(srv_data_file_names);
srv_data_file_names = NULL;
free(srv_data_file_sizes);
srv_data_file_sizes = NULL;
free(srv_data_file_is_raw_partition);
srv_data_file_is_raw_partition = NULL;
free(srv_log_group_home_dirs);
srv_log_group_home_dirs = NULL;
}
#ifndef UNIV_HOTBACKUP
/************************************************************************
I/o-handler thread function. */
......
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