mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 11:27:39 +02:00
Fixed a bug in mysqladmin, when it could hang while waiting for
pid file to disappear, when MySQL was already re-started.
This commit is contained in:
parent
2466b5b9b3
commit
cbd4e667a9
1 changed files with 26 additions and 6 deletions
|
|
@ -69,7 +69,8 @@ static void print_relative_header();
|
|||
static void print_relative_line();
|
||||
static void truncate_names();
|
||||
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);
|
||||
|
||||
/*
|
||||
|
|
@ -453,13 +454,23 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
case ADMIN_SHUTDOWN:
|
||||
{
|
||||
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
|
||||
If pidfile doesn't exist, continue without pid file checking
|
||||
*/
|
||||
if (mysql->unix_socket)
|
||||
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))
|
||||
{
|
||||
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)
|
|||
{
|
||||
if (opt_verbose)
|
||||
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;
|
||||
}
|
||||
|
|
@ -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];
|
||||
int fd;
|
||||
uint count=0;
|
||||
|
||||
system_filename(buff,pidfile);
|
||||
system_filename(buff, pidfile);
|
||||
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));
|
||||
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)
|
||||
{
|
||||
my_close(fd,MYF(0));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue