summaryrefslogtreecommitdiff
path: root/server-tools/instance-manager/instance.cc
diff options
context:
space:
mode:
authorunknown <jimw@rama.(none)>2006-07-12 12:30:22 -0700
committerunknown <jimw@rama.(none)>2006-07-12 12:30:22 -0700
commit812c9cc84acdde17da62a804c720f465ff72c292 (patch)
tree3a6a3ca3bba5cb4bfbd49895d54314e32ea337c4 /server-tools/instance-manager/instance.cc
parent67d53e36cdbcc4cdf5dc785a5f465c1e1bc7fdbe (diff)
downloadmariadb-git-812c9cc84acdde17da62a804c720f465ff72c292.tar.gz
Bug #12673: Instance Manager: allows to stop the instance many times
The instance manager was not actually checking whether an instance was actually running before trying to stop it. Now it checks first. mysql-test/r/im_life_cycle.result: Add new results mysql-test/t/im_life_cycle.imtest: Add new regression test server-tools/instance-manager/instance.cc: Fix Instance::stop() to report ER_INSTANCE_IS_NOT_STARTED when that is the case. Also removed unnecessary goto. server-tools/instance-manager/messages.cc: Fix messages with missing spaces
Diffstat (limited to 'server-tools/instance-manager/instance.cc')
-rw-r--r--server-tools/instance-manager/instance.cc45
1 files changed, 23 insertions, 22 deletions
diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc
index 39381b457ab..2ed369ba245 100644
--- a/server-tools/instance-manager/instance.cc
+++ b/server-tools/instance-manager/instance.cc
@@ -469,37 +469,38 @@ int Instance::stop()
struct timespec timeout;
uint waitchild= (uint) DEFAULT_SHUTDOWN_DELAY;
- if (options.shutdown_delay_val)
- waitchild= options.shutdown_delay_val;
+ if (is_running())
+ {
+ if (options.shutdown_delay_val)
+ waitchild= options.shutdown_delay_val;
- kill_instance(SIGTERM);
- /* sleep on condition to wait for SIGCHLD */
+ kill_instance(SIGTERM);
+ /* sleep on condition to wait for SIGCHLD */
- timeout.tv_sec= time(NULL) + waitchild;
- timeout.tv_nsec= 0;
- if (pthread_mutex_lock(&LOCK_instance))
- goto err;
+ timeout.tv_sec= time(NULL) + waitchild;
+ timeout.tv_nsec= 0;
+ if (pthread_mutex_lock(&LOCK_instance))
+ return ER_STOP_INSTANCE;
- while (options.get_pid() != 0) /* while server isn't stopped */
- {
- int status;
+ while (options.get_pid() != 0) /* while server isn't stopped */
+ {
+ int status;
- status= pthread_cond_timedwait(&COND_instance_stopped,
- &LOCK_instance,
- &timeout);
- if (status == ETIMEDOUT || status == ETIME)
- break;
- }
+ status= pthread_cond_timedwait(&COND_instance_stopped,
+ &LOCK_instance,
+ &timeout);
+ if (status == ETIMEDOUT || status == ETIME)
+ break;
+ }
- pthread_mutex_unlock(&LOCK_instance);
+ pthread_mutex_unlock(&LOCK_instance);
- kill_instance(SIGKILL);
+ kill_instance(SIGKILL);
- return 0;
+ return 0;
+ }
return ER_INSTANCE_IS_NOT_STARTED;
-err:
- return ER_STOP_INSTANCE;
}
#ifdef __WIN__