diff options
Diffstat (limited to 'innobase/srv/srv0start.c')
-rw-r--r-- | innobase/srv/srv0start.c | 105 |
1 files changed, 63 insertions, 42 deletions
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 7b50877709b..68fcb82c6d8 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -63,13 +63,13 @@ dulint srv_shutdown_lsn; ibool srv_start_raw_disk_in_use = FALSE; -ibool srv_start_has_been_called = FALSE; +static ibool srv_start_has_been_called = FALSE; ulint srv_sizeof_trx_t_in_ha_innodb_cc; ibool srv_startup_is_before_trx_rollback_phase = FALSE; ibool srv_is_being_started = FALSE; -ibool srv_was_started = FALSE; +static ibool srv_was_started = FALSE; /* At a shutdown the value first climbs to SRV_SHUTDOWN_CLEANUP and then to SRV_SHUTDOWN_LAST_PHASE */ @@ -77,19 +77,20 @@ ulint srv_shutdown_state = 0; ibool measure_cont = FALSE; -os_file_t files[1000]; +static os_file_t files[1000]; -mutex_t ios_mutex; -ulint ios; +static mutex_t ios_mutex; +static ulint ios; -ulint n[SRV_MAX_N_IO_THREADS + 5]; -os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 5]; +static ulint n[SRV_MAX_N_IO_THREADS + 5]; +static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 5]; /* We use this mutex to test the return value of pthread_mutex_trylock on successful locking. HP-UX does NOT return 0, though Linux et al do. */ -os_fast_mutex_t srv_os_test_mutex; +static os_fast_mutex_t srv_os_test_mutex; -ibool srv_os_test_mutex_is_locked = FALSE; +/* Name of srv_monitor_file */ +static char* srv_monitor_file_name; #define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD #define SRV_MAX_N_PENDING_SYNC_IOS 100 @@ -161,17 +162,13 @@ srv_parse_data_file_paths_and_sizes( str++; } - if (strlen(str) >= ut_strlen(":autoextend") - && 0 == ut_memcmp(str, (char*)":autoextend", - ut_strlen(":autoextend"))) { + if (0 == memcmp(str, ":autoextend", (sizeof ":autoextend") - 1)) { - str += ut_strlen(":autoextend"); + str += (sizeof ":autoextend") - 1; - if (strlen(str) >= ut_strlen(":max:") - && 0 == ut_memcmp(str, (char*)":max:", - ut_strlen(":max:"))) { + if (0 == memcmp(str, ":max:", (sizeof ":max:") - 1)) { - str += ut_strlen(":max:"); + str += (sizeof ":max:") - 1; size = strtoul(str, &endp, 10); @@ -200,10 +197,7 @@ srv_parse_data_file_paths_and_sizes( str += 3; } - if (strlen(str) >= 3 - && *str == 'r' - && *(str + 1) == 'a' - && *(str + 2) == 'w') { + if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') { str += 3; } @@ -269,19 +263,15 @@ srv_parse_data_file_paths_and_sizes( (*data_file_names)[i] = path; (*data_file_sizes)[i] = size; - if (strlen(str) >= ut_strlen(":autoextend") - && 0 == ut_memcmp(str, (char*)":autoextend", - ut_strlen(":autoextend"))) { + if (0 == memcmp(str, ":autoextend", (sizeof ":autoextend") - 1)) { *is_auto_extending = TRUE; - str += ut_strlen(":autoextend"); + str += (sizeof ":autoextend") - 1; - if (strlen(str) >= ut_strlen(":max:") - && 0 == ut_memcmp(str, (char*)":max:", - ut_strlen(":max:"))) { + if (0 == memcmp(str, ":max:", (sizeof ":max:") - 1)) { - str += ut_strlen(":max:"); + str += (sizeof ":max:") - 1; size = strtoul(str, &endp, 10); @@ -315,10 +305,7 @@ srv_parse_data_file_paths_and_sizes( (*data_file_is_raw_partition)[i] = SRV_NEW_RAW; } - if (strlen(str) >= 3 - && *str == 'r' - && *(str + 1) == 'a' - && *(str + 2) == 'w') { + if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') { str += 3; if ((*data_file_is_raw_partition)[i] == 0) { @@ -420,8 +407,8 @@ io_handler_thread( segment = *((ulint*)arg); #ifdef UNIV_DEBUG_THREAD_CREATION - printf("Io handler thread %lu starts, id %lu\n", segment, - os_thread_pf(os_thread_get_curr_id())); + fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment, + os_thread_pf(os_thread_get_curr_id())); #endif for (i = 0;; i++) { fil_aio_wait(segment); @@ -461,12 +448,10 @@ srv_normalize_path_for_win( character string */ { #ifdef __WIN__ - ulint i; - - for (i = 0; i < ut_strlen(str); i++) { + for (; *str; str++) { - if (str[i] == '/') { - str[i] = '\\'; + if (*str == '/') { + *str = '\\'; } } #endif @@ -535,8 +520,8 @@ ulint open_or_create_log_file( /*====================*/ /* out: DB_SUCCESS or error code */ - ibool create_new_db, /* in: TRUE if we should create a - new database */ + ibool create_new_db, /* in: TRUE if we should create a + new database */ ibool* log_file_created, /* out: TRUE if new log file created */ ibool log_file_has_been_opened,/* in: TRUE if a log file has been @@ -558,6 +543,8 @@ open_or_create_log_file( srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed( srv_log_group_home_dirs[k]); + ut_a(strlen(srv_log_group_home_dirs[k]) < + (sizeof name) - 10 - sizeof "ib_logfile"); sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k], "ib_logfile", (ulong) i); files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL, @@ -709,6 +696,8 @@ open_or_create_data_files( for (i = 0; i < srv_n_data_files; i++) { srv_normalize_path_for_win(srv_data_file_names[i]); + ut_a(strlen(srv_data_home) + strlen(srv_data_file_names[i]) + < (sizeof name) - 1); sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]); if (srv_data_file_is_raw_partition[i] == 0) { @@ -1122,6 +1111,20 @@ NetWare. */ return((int) err); } + mutex_create(&srv_monitor_file_mutex); + mutex_set_level(&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK); + srv_monitor_file_name = mem_alloc( + strlen(fil_path_to_mysql_datadir) + + 20 + sizeof "/innodb_status."); + sprintf(srv_monitor_file_name, "%s/innodb.status.%lu", + fil_path_to_mysql_datadir, os_proc_get_number()); + srv_monitor_file = fopen(srv_monitor_file_name, "w+"); + if (!srv_monitor_file) { + fprintf(stderr, "InnoDB: unable to create %s: %s\n", + srv_monitor_file_name, strerror(errno)); + return(DB_ERROR); + } + /* Restrict the maximum number of file i/o threads */ if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) { @@ -1457,7 +1460,9 @@ NetWare. */ os_thread_create(&srv_master_thread, NULL, thread_ids + 1 + SRV_MAX_N_IO_THREADS); +#ifdef UNIV_DEBUG /* buf_debug_prints = TRUE; */ +#endif /* UNIV_DEBUG */ sum_of_data_file_sizes = 0; @@ -1663,6 +1668,15 @@ innobase_shutdown_for_mysql(void) (ulong) os_thread_count); } + if (srv_monitor_file) { + fclose(srv_monitor_file); + srv_monitor_file = 0; + unlink(srv_monitor_file_name); + mem_free(srv_monitor_file_name); + } + + mutex_free(&srv_monitor_file_mutex); + /* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside them */ @@ -1689,6 +1703,13 @@ innobase_shutdown_for_mysql(void) (ulong) os_mutex_count, (ulong) os_fast_mutex_count); } + if (dict_foreign_err_file) { + fclose(dict_foreign_err_file); + } + if (lock_latest_err_file) { + fclose(lock_latest_err_file); + } + if (srv_print_verbose_log) { ut_print_timestamp(stderr); fprintf(stderr, |