Commit 4da80772 authored by unknown's avatar unknown

Polishing + make the code compiled on Windows.


server-tools/instance-manager/listener.cc:
  Polishing: declare variable prior to the first statement in block.
server-tools/instance-manager/listener.h:
  Polishing.
server-tools/instance-manager/manager.cc:
  Make Manager::manager_pid local variable.
server-tools/instance-manager/manager.h:
  Make Manager::manager_pid local variable.
server-tools/instance-manager/thread_registry.cc:
  Polsihing.
parent bc06af9d
...@@ -82,12 +82,12 @@ void Listener::run() ...@@ -82,12 +82,12 @@ void Listener::run()
{ {
int i, n= 0; int i, n= 0;
log_info("Listener: started.");
#ifndef __WIN__ #ifndef __WIN__
struct sockaddr_un unix_socket_address; struct sockaddr_un unix_socket_address;
#endif #endif
log_info("Listener: started.");
thread_registry->register_thread(&thread_info); thread_registry->register_thread(&thread_info);
FD_ZERO(&read_fds); FD_ZERO(&read_fds);
......
...@@ -34,21 +34,28 @@ class Listener: public Thread ...@@ -34,21 +34,28 @@ class Listener: public Thread
{ {
public: public:
Listener(Thread_registry *thread_registry_arg, User_map *user_map_arg); Listener(Thread_registry *thread_registry_arg, User_map *user_map_arg);
protected: protected:
virtual void run(); virtual void run();
private:
static const int LISTEN_BACK_LOG_SIZE= 5; /* standard backlog size */
private: private:
Thread_info thread_info; Thread_info thread_info;
Thread_registry *thread_registry; Thread_registry *thread_registry;
User_map *user_map; User_map *user_map;
static const int LISTEN_BACK_LOG_SIZE= 5; /* standard backlog size */
ulong total_connection_count; ulong total_connection_count;
int sockets[2]; int sockets[2];
int num_sockets; int num_sockets;
fd_set read_fds; fd_set read_fds;
private:
void handle_new_mysql_connection(struct st_vio *vio); void handle_new_mysql_connection(struct st_vio *vio);
int create_tcp_socket(); int create_tcp_socket();
int create_unix_socket(struct sockaddr_un &unix_socket_address); int create_unix_socket(struct sockaddr_un &unix_socket_address);
}; };
#endif // INCLUDES_MYSQL_INSTANCE_MANAGER_LISTENER_H #endif // INCLUDES_MYSQL_INSTANCE_MANAGER_LISTENER_H
...@@ -114,7 +114,6 @@ Guardian *Manager::p_guardian; ...@@ -114,7 +114,6 @@ Guardian *Manager::p_guardian;
Instance_map *Manager::p_instance_map; Instance_map *Manager::p_instance_map;
Thread_registry *Manager::p_thread_registry; Thread_registry *Manager::p_thread_registry;
User_map *Manager::p_user_map; User_map *Manager::p_user_map;
pid_t Manager::manager_pid;
/* /*
manager - entry point to the main instance manager process: start manager - entry point to the main instance manager process: start
...@@ -131,6 +130,7 @@ int Manager::main() ...@@ -131,6 +130,7 @@ int Manager::main()
int rc= 1; int rc= 1;
const char *err_msg; const char *err_msg;
bool shutdown_complete= FALSE; bool shutdown_complete= FALSE;
pid_t manager_pid= getpid();
Thread_registry thread_registry; Thread_registry thread_registry;
/* /*
...@@ -146,7 +146,6 @@ int Manager::main() ...@@ -146,7 +146,6 @@ int Manager::main()
Listener listener(&thread_registry, &user_map); Listener listener(&thread_registry, &user_map);
manager_pid= getpid();
p_instance_map= &instance_map; p_instance_map= &instance_map;
p_guardian= instance_map.guardian= &guardian; p_guardian= instance_map.guardian= &guardian;
p_thread_registry= &thread_registry; p_thread_registry= &thread_registry;
......
...@@ -38,12 +38,11 @@ public: ...@@ -38,12 +38,11 @@ public:
static Guardian *get_guardian() { return p_guardian; } static Guardian *get_guardian() { return p_guardian; }
static Thread_registry *get_thread_registry() { return p_thread_registry; } static Thread_registry *get_thread_registry() { return p_thread_registry; }
static User_map *get_user_map() { return p_user_map; } static User_map *get_user_map() { return p_user_map; }
static pid_t get_manager_pid() { return manager_pid; }
private: private:
static void stop_all_threads(); static void stop_all_threads();
private: private:
static pid_t manager_pid;
static Guardian *p_guardian; static Guardian *p_guardian;
static Instance_map *p_instance_map; static Instance_map *p_instance_map;
static Thread_registry *p_thread_registry; static Thread_registry *p_thread_registry;
......
...@@ -371,7 +371,7 @@ bool Thread::start_detached() ...@@ -371,7 +371,7 @@ bool Thread::start_detached()
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
rc= set_stacksize_and_create_thread(&thd_id, &attr, rc= set_stacksize_and_create_thread(&thd_id, &attr,
Thread::thread_func, this); Thread::thread_func, this);
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
return rc != 0; return rc != 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