diff options
author | unknown <petr@mysql.com> | 2005-01-25 13:54:56 +0300 |
---|---|---|
committer | unknown <petr@mysql.com> | 2005-01-25 13:54:56 +0300 |
commit | fb3d6c39a0dc128f5310aac2906cc1e6c6b7db59 (patch) | |
tree | ada085796e1dc8387942522e6233d9a1b1a1d6d3 /server-tools/instance-manager/guardian.cc | |
parent | 28f86d8ff1d042a2224c64712e31c65b1d6b7476 (diff) | |
download | mariadb-git-fb3d6c39a0dc128f5310aac2906cc1e6c6b7db59.tar.gz |
IM mostly fixed according to Brian's directions. Will need to do some additional option handling and cleanups
server-tools/instance-manager/Makefile.am:
New file added
server-tools/instance-manager/client_func.c:
typo fixed
server-tools/instance-manager/commands.cc:
there are no admin-user snd admin-password fields anymore, so no need to show their values
server-tools/instance-manager/guardian.cc:
Syncronization added -- now guardian wakes up whenever SIGCLD has been catched
server-tools/instance-manager/guardian.h:
Condition variable declared
server-tools/instance-manager/instance.cc:
Persistent connection to the instance removed. Now we use SIGTERM instead of com_shutdown for STOP. We also
manage SIGCHLD ourselves now (therefore no double fork).
server-tools/instance-manager/instance.h:
Pointer to the instance_map added, MySQL connection structures removed
server-tools/instance-manager/instance_map.cc:
More syncronization added (to make proper STOP)
server-tools/instance-manager/instance_map.h:
added condition variable and mutex for connection threads to wait for SIGCHLD
server-tools/instance-manager/instance_options.cc:
defaults-handling methods have been added.
server-tools/instance-manager/instance_options.h:
New functions and constants declared
server-tools/instance-manager/listener.cc:
No changes here (bk bug?)
server-tools/instance-manager/manager.cc:
SIGCHLD handling added
Diffstat (limited to 'server-tools/instance-manager/guardian.cc')
-rw-r--r-- | server-tools/instance-manager/guardian.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc index 7375453673b..f68ef6575a0 100644 --- a/server-tools/instance-manager/guardian.cc +++ b/server-tools/instance-manager/guardian.cc @@ -45,6 +45,7 @@ Guardian_thread::Guardian_thread(Thread_registry &thread_registry_arg, thread_info(pthread_self()) { pthread_mutex_init(&LOCK_guardian, 0); + pthread_cond_init(&COND_guardian, 0); thread_registry.register_thread(&thread_info); init_alloc_root(&alloc, MEM_ROOT_BLOCK_SIZE, 0); guarded_instances= NULL; @@ -60,6 +61,7 @@ Guardian_thread::~Guardian_thread() thread_registry.unregister_thread(&thread_info); pthread_mutex_unlock(&LOCK_guardian); pthread_mutex_destroy(&LOCK_guardian); + pthread_cond_destroy(&COND_guardian); } @@ -79,27 +81,32 @@ void Guardian_thread::run() { Instance *instance; LIST *loop; + struct timespec timeout; my_thread_init(); + pthread_mutex_lock(&LOCK_guardian); + while (!thread_registry.is_shutdown()) { - pthread_mutex_lock(&LOCK_guardian); loop= guarded_instances; while (loop != NULL) { instance= (Instance *) loop->data; - /* instance-> start already checks whether instance is running */ + /* instance-> start already checks whether the instance is running */ if (instance->start() != ER_INSTANCE_ALREADY_STARTED) log_info("guardian attempted to restart instance %s", instance->options.instance_name); loop= loop->next; } move_to_list(&starting_instances, &guarded_instances); - pthread_mutex_unlock(&LOCK_guardian); - sleep(monitoring_interval); + timeout.tv_sec= time(NULL) + monitoring_interval; + timeout.tv_nsec= 0; + + pthread_cond_timedwait(&COND_guardian, &LOCK_guardian, &timeout); } + pthread_mutex_unlock(&LOCK_guardian); my_thread_end(); } |