log0log.c InnoDB now prints timestamp at startup and shutdown

srv0start.c	InnoDB now prints timestamp at startup and shutdown
ut0ut.h 	InnoDB now prints timestamp at startup and shutdown
ut0ut.c 	InnoDB now prints timestamp at startup and shutdown
This commit is contained in:
heikki@donna.mysql.fi 2001-05-24 22:35:14 +03:00
parent 1993f26881
commit 125b4bd6ba
4 changed files with 53 additions and 5 deletions

View File

@ -136,6 +136,13 @@ ut_difftime(
/* out: time2 - time1 expressed in seconds */
ib_time_t time2, /* in: time */
ib_time_t time1); /* in: time */
/**************************************************************
Prints a timestamp to a file. */
void
ut_print_timestamp(
/*===============*/
FILE* file); /* in: file where to print */
/*****************************************************************
Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++. */

View File

@ -2635,6 +2635,7 @@ logs_empty_and_mark_files_at_shutdown(void)
dulint lsn;
ulint arch_log_no;
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Starting shutdown...\n");
/* Wait until the master thread and all other operations are idle: our
@ -2725,6 +2726,7 @@ loop:
fil_flush_file_spaces(FIL_TABLESPACE);
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Shutdown completed\n");
}

View File

@ -813,6 +813,7 @@ innobase_start_or_create_for_mysql(void)
/* Create the thread which watches the timeouts for lock waits */
os_thread_create(&srv_lock_timeout_monitor_thread, NULL,
thread_ids + 2 + SRV_MAX_N_IO_THREADS);
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Started\n");
srv_was_started = TRUE;
@ -835,8 +836,9 @@ innobase_shutdown_for_mysql(void)
{
if (!srv_was_started) {
if (srv_is_being_started) {
ut_print_timestamp(stderr);
fprintf(stderr,
"InnoDB: Warning: shutting down not properly started database\n");
" InnoDB: Warning: shutting down a not properly started database\n");
}
return(DB_SUCCESS);
}

View File

@ -49,6 +49,43 @@ ut_difftime(
return(difftime(time2, time1));
}
/**************************************************************
Prints a timestamp to a file. */
void
ut_print_timestamp(
/*===============*/
FILE* file) /* in: file where to print */
{
struct tm* cal_tm_ptr;
struct tm cal_tm;
time_t tm;
try_again:
time(&tm);
cal_tm_ptr = localtime(&tm);
memcpy(&cal_tm, cal_tm_ptr, sizeof(struct tm));
/* In theory localtime may return a wrong result because its return
struct is not protected with a mutex */
if (difftime(tm, mktime(&cal_tm)) > 0.5
|| difftime(tm, mktime(&cal_tm)) < -0.5) {
goto try_again;
}
fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
cal_tm.tm_year % 100,
cal_tm.tm_mon+1,
cal_tm.tm_mday,
cal_tm.tm_hour,
cal_tm.tm_min,
cal_tm.tm_sec);
}
/*****************************************************************
Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++. */