mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
BUG#14726272- BACKPORT FIX FOR BUG 11746142 TO 5.5 AND 5.1
Merging fix from mysql-5.1
This commit is contained in:
@ -993,6 +993,7 @@ static void clean_up(bool print_message);
|
||||
static int test_if_case_insensitive(const char *dir_name);
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
static bool pid_file_created= false;
|
||||
static void usage(void);
|
||||
static void start_signal_handler(void);
|
||||
static void close_server_sock();
|
||||
@ -1001,6 +1002,7 @@ static void wait_for_signal_thread_to_end(void);
|
||||
static void create_pid_file();
|
||||
static void mysqld_exit(int exit_code) __attribute__((noreturn));
|
||||
#endif
|
||||
static void delete_pid_file(myf flags);
|
||||
static void end_ssl();
|
||||
|
||||
|
||||
@ -1515,10 +1517,8 @@ void clean_up(bool print_message)
|
||||
debug_sync_end();
|
||||
#endif /* defined(ENABLED_DEBUG_SYNC) */
|
||||
|
||||
#if !defined(EMBEDDED_LIBRARY)
|
||||
if (!opt_bootstrap)
|
||||
mysql_file_delete(key_file_pid, pidfile_name, MYF(0)); // This may not always exist
|
||||
#endif
|
||||
delete_pid_file(MYF(0));
|
||||
|
||||
if (print_message && my_default_lc_messages && server_start_time)
|
||||
sql_print_information(ER_DEFAULT(ER_SHUTDOWN_COMPLETE),my_progname);
|
||||
cleanup_errmsgs();
|
||||
@ -4517,9 +4517,7 @@ int mysqld_main(int argc, char **argv)
|
||||
|
||||
(void) pthread_kill(signal_thread, MYSQL_KILL_SIGNAL);
|
||||
|
||||
|
||||
if (!opt_bootstrap)
|
||||
mysql_file_delete(key_file_pid, pidfile_name, MYF(MY_WME)); // Not needed anymore
|
||||
delete_pid_file(MYF(MY_WME));
|
||||
|
||||
if (unix_sock != INVALID_SOCKET)
|
||||
unlink(mysqld_unix_port);
|
||||
@ -7676,13 +7674,14 @@ static void create_pid_file()
|
||||
if ((file= mysql_file_create(key_file_pid, pidfile_name, 0664,
|
||||
O_WRONLY | O_TRUNC, MYF(MY_WME))) >= 0)
|
||||
{
|
||||
char buff[21], *end;
|
||||
char buff[MAX_BIGINT_WIDTH + 1], *end;
|
||||
end= int10_to_str((long) getpid(), buff, 10);
|
||||
*end++= '\n';
|
||||
if (!mysql_file_write(file, (uchar*) buff, (uint) (end-buff),
|
||||
MYF(MY_WME | MY_NABP)))
|
||||
{
|
||||
mysql_file_close(file, MYF(0));
|
||||
pid_file_created= true;
|
||||
return;
|
||||
}
|
||||
mysql_file_close(file, MYF(0));
|
||||
@ -7692,6 +7691,39 @@ static void create_pid_file()
|
||||
}
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
||||
/**
|
||||
Remove the process' pid file.
|
||||
|
||||
@param flags file operation flags
|
||||
*/
|
||||
|
||||
static void delete_pid_file(myf flags)
|
||||
{
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
File file;
|
||||
if (opt_bootstrap ||
|
||||
!pid_file_created ||
|
||||
!(file= mysql_file_open(key_file_pid, pidfile_name,
|
||||
O_RDONLY, flags)))
|
||||
return;
|
||||
|
||||
/* Make sure that the pid file was created by the same process. */
|
||||
uchar buff[MAX_BIGINT_WIDTH + 1];
|
||||
size_t error= mysql_file_read(file, buff, sizeof(buff), flags);
|
||||
mysql_file_close(file, flags);
|
||||
buff[sizeof(buff) - 1]= '\0';
|
||||
if (error != MY_FILE_ERROR &&
|
||||
atol((char *) buff) == (long) getpid())
|
||||
{
|
||||
mysql_file_delete(key_file_pid, pidfile_name, flags);
|
||||
pid_file_created= false;
|
||||
}
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** Clear most status variables. */
|
||||
void refresh_status(THD *thd)
|
||||
{
|
||||
|
Reference in New Issue
Block a user