summaryrefslogtreecommitdiff
path: root/support-files
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2008-03-19 18:13:56 -0400
committerunknown <cmiller@zippy.cornsilk.net>2008-03-19 18:13:56 -0400
commit8dad72ee4cf108e206ec93a1a46c96a6d9950e7e (patch)
treed9236ade5368d6873199d2e64eb5602516ad0da8 /support-files
parent51f198447beb8e656b542f3a356e0093591f5b72 (diff)
downloadmariadb-git-8dad72ee4cf108e206ec93a1a46c96a6d9950e7e.tar.gz
Bug#30378: mysql.server needs to skip wait_for_pid() when mysqld \
isn't running Pass the process id of the manager as a parameter to "wait_for_pid" and if the manager isn't running, then do not continue to wait. Also, capture the error message of our process-existence test, "kill -0", as we expect errors and shouldn't pass them to the user. Additionally, be a bit more descriptive of what the problem is. support-files/mysql.server.sh: Test that the PID-file's manager is running while we're waiting for something to happen with the pid-file. Capture the error message of our process-existence test, "kill -0", as we expect errors and shouldn't pass them to the user. Additionally, be a bit more descriptive of what the problem is.
Diffstat (limited to 'support-files')
-rw-r--r--support-files/mysql.server.sh31
1 files changed, 27 insertions, 4 deletions
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index 0a87b04c992..be8a8bd741e 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -150,22 +150,45 @@ parse_manager_arguments() {
}
wait_for_pid () {
+ verb="$1"
+ manager_pid="$2" # process ID of the program operating on the pid-file
i=0
+ avoid_race_condition="by checking again"
while test $i -ne $service_startup_timeout ; do
sleep 1
- case "$1" in
+
+ case "$verb" in
'created')
+ # wait for a PID-file to pop into existence.
test -s $pid_file && i='' && break
- kill -0 $2 || break # if the program goes away, stop waiting
;;
'removed')
+ # wait for this PID-file to disappear
test ! -s $pid_file && i='' && break
;;
*)
- echo "wait_for_pid () usage: wait_for_pid created|removed"
+ echo "wait_for_pid () usage: wait_for_pid created|removed manager_pid"
exit 1
;;
esac
+
+ # if manager isn't running, then pid-file will never be updated
+ if test -n "$manager_pid"; then
+ if kill -0 "$manager_pid" 2>/dev/null; then
+ : # the manager still runs
+ else
+ # The manager may have exited between the last pid-file check and now.
+ if test -n "$avoid_race_condition"; then
+ avoid_race_condition=""
+ continue # Check again.
+ fi
+
+ # there's nothing that will affect the file.
+ log_failure_msg "Manager of pid-file quit without updating file."
+ return 1 # not waiting any more.
+ fi
+ fi
+
echo $echo_n ".$echo_c"
i=`expr $i + 1`
done
@@ -335,7 +358,7 @@ case "$mode" in
echo $echo_n "Shutting down MySQL"
kill $mysqlmanager_pid
# mysqlmanager should remove the pid_file when it exits, so wait for it.
- wait_for_pid removed; return_value=$?
+ wait_for_pid removed "$mysqlmanager_pid"; return_value=$?
# delete lock for RedHat / SuSE
if test -f $lock_dir