mariadb/server-tools/instance-manager/priv.cc
unknown a163ae30f2 Replace the approach using Foo_thread_args + Foo_thread and manually
spawned threads with a reusable class Thread.

This is the second idea implemented in the Alik's patch for
BUG#22306: STOP INSTANCE can not be applied for instances in Crashed,
Failed and Abandoned.
Commiting separately to ease review process. 


server-tools/instance-manager/commands.cc:
  Remove an unused header.
server-tools/instance-manager/guardian.cc:
  Use Thread framework instead of manually spawning the Guardian thread.
  Tidy up.
server-tools/instance-manager/guardian.h:
  Use Thread framework instead of manually spawning the Guardian thread.
server-tools/instance-manager/instance.cc:
  Use Thread framework instead of manually spawning the instance
  monitoring thread.
server-tools/instance-manager/listener.cc:
  Use Thread framework instead of manually spawning the 
  mysql connection thread.
server-tools/instance-manager/listener.h:
  Use Thread framework instead of manually spawning the 
  mysql connection thread.
  Rename Listener_thread to Listener for brevity.
server-tools/instance-manager/manager.cc:
  Change references to pointers, as per the coding style.
  Use Thread framework instead of manually spawning threads.
server-tools/instance-manager/mysql_connection.cc:
  Get rid of Mysql_connection_thread_args. Use class Thread framework
  instead. Rename Mysql_connection_thread to Mysql_connection for brevity.
server-tools/instance-manager/mysql_connection.h:
  Get rid of Mysql_connection_thread_args. Use class Thread framework
  instead. Rename Mysql_connection_thread to Mysql_connection for brevity.
server-tools/instance-manager/priv.cc:
  Move set_stacksize_and_create_thread to thread_registry.cc and make it
  static: it is not used anywhere else now.
server-tools/instance-manager/priv.h:
  No public set_stacksize_n_create_thread
server-tools/instance-manager/thread_registry.cc:
  Implement a base Thread class to be used for all Instance Manager
  threads.
server-tools/instance-manager/thread_registry.h:
  Implement a base Thread class to be used for all Instance Manager
  threads.
2006-11-17 16:11:04 +03:00

86 lines
2.5 KiB
C++

/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "priv.h"
#include <my_global.h>
#include <mysql_com.h>
#include <my_sys.h>
#include "log.h"
/* the pid of the manager process (of the signal thread on the LinuxThreads) */
pid_t manager_pid;
/*
This flag is set if mysqlmanager has detected that it is running on the
system using LinuxThreads
*/
bool linuxthreads;
/*
The following string must be less then 80 characters, as
mysql_connection.cc relies on it
*/
const LEX_STRING mysqlmanager_version= { C_STRING_WITH_LEN("1.0-beta") };
const unsigned char protocol_version= PROTOCOL_VERSION;
unsigned long net_buffer_length= 16384;
unsigned long max_allowed_packet= 16384;
unsigned long net_read_timeout= NET_WAIT_TIMEOUT; // same as in mysqld
unsigned long net_write_timeout= 60; // same as in mysqld
unsigned long net_retry_count= 10; // same as in mysqld
/* needed by net_serv.cc */
unsigned int test_flags= 0;
unsigned long bytes_sent = 0L, bytes_received = 0L;
unsigned long mysqld_net_retry_count = 10L;
unsigned long open_files_limit;
int create_pid_file(const char *pid_file_name, int pid)
{
FILE *pid_file;
if (!(pid_file= my_fopen(pid_file_name, O_WRONLY | O_CREAT | O_BINARY,
MYF(0))))
{
log_error("Error: can not create pid file '%s': %s (errno: %d)",
(const char *) pid_file_name,
(const char *) strerror(errno),
(int) errno);
return 1;
}
if (fprintf(pid_file, "%d\n", (int) pid) <= 0)
{
log_error("Error: can not write to pid file '%s': %s (errno: %d)",
(const char *) pid_file_name,
(const char *) strerror(errno),
(int) errno);
return 1;
}
my_fclose(pid_file, MYF(0));
return 0;
}