Commit 388f8ff9 authored by unknown's avatar unknown

Merge work:/home/bk/mysql-4.0/

into rhols221.adsl.netsonic.fi:/home/my/bk/mysql-4.0
parents 8c8c2a7b 48b3653e
...@@ -69,7 +69,8 @@ static void print_relative_header(); ...@@ -69,7 +69,8 @@ static void print_relative_header();
static void print_relative_line(); static void print_relative_line();
static void truncate_names(); static void truncate_names();
static my_bool get_pidfile(MYSQL *mysql, char *pidfile); static my_bool get_pidfile(MYSQL *mysql, char *pidfile);
static void wait_pidfile(char *pidfile); static void wait_pidfile(char *pidfile, my_bool check_pidfile_status,
time_t last_modified, struct stat pidfile_status);
static void store_values(MYSQL_RES *result); static void store_values(MYSQL_RES *result);
/* /*
...@@ -453,13 +454,23 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) ...@@ -453,13 +454,23 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
case ADMIN_SHUTDOWN: case ADMIN_SHUTDOWN:
{ {
char pidfile[FN_REFLEN]; char pidfile[FN_REFLEN];
my_bool got_pidfile=0; my_bool got_pidfile= 0;
time_t last_modified= 0; /* to keep compiler happy */
struct stat pidfile_status;
my_bool check_pidfile_status= 1;
/* /*
Only wait for pidfile on local connections Only wait for pidfile on local connections
If pidfile doesn't exist, continue without pid file checking If pidfile doesn't exist, continue without pid file checking
*/ */
if (mysql->unix_socket) if (mysql->unix_socket)
got_pidfile= !get_pidfile(mysql, pidfile); got_pidfile= !get_pidfile(mysql, pidfile);
if (got_pidfile && stat(pidfile, &pidfile_status))
check_pidfile_status= 0;
else
last_modified= pidfile_status.st_mtime;
if (mysql_shutdown(mysql)) if (mysql_shutdown(mysql))
{ {
my_printf_error(0,"shutdown failed; error: '%s'",MYF(ME_BELL), my_printf_error(0,"shutdown failed; error: '%s'",MYF(ME_BELL),
...@@ -471,7 +482,10 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) ...@@ -471,7 +482,10 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
{ {
if (opt_verbose) if (opt_verbose)
printf("Shutdown signal sent to server; Waiting for pid file to disappear\n"); printf("Shutdown signal sent to server; Waiting for pid file to disappear\n");
wait_pidfile(pidfile); /* Wait until pid file is gone */
/* Wait until pid file is gone */
wait_pidfile(pidfile, check_pidfile_status, last_modified,
pidfile_status);
} }
break; break;
} }
...@@ -1101,19 +1115,25 @@ static my_bool get_pidfile(MYSQL *mysql, char *pidfile) ...@@ -1101,19 +1115,25 @@ static my_bool get_pidfile(MYSQL *mysql, char *pidfile)
} }
static void wait_pidfile(char *pidfile) static void wait_pidfile(char *pidfile, my_bool check_pidfile_status,
time_t last_modified, struct stat pidfile_status)
{ {
char buff[FN_REFLEN]; char buff[FN_REFLEN];
int fd; int fd;
uint count=0; uint count=0;
system_filename(buff,pidfile); system_filename(buff, pidfile);
while ((fd = my_open(buff, O_RDONLY, MYF(0))) >= 0 && while ((fd = my_open(buff, O_RDONLY, MYF(0))) >= 0 &&
count++ < opt_shutdown_timeout && !interrupted) count++ < opt_shutdown_timeout && !interrupted &&
(!check_pidfile_status || (last_modified == pidfile_status.st_mtime)))
{ {
my_close(fd,MYF(0)); my_close(fd,MYF(0));
sleep(1); sleep(1);
if (stat(pidfile, &pidfile_status))
check_pidfile_status= 0;
} }
if (check_pidfile_status && (last_modified != pidfile_status.st_mtime))
printf("Warning; pid file changed while waiting for it to disappear!\n");
if (fd >= 0) if (fd >= 0)
{ {
my_close(fd,MYF(0)); my_close(fd,MYF(0));
......
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