init.d/sanlock | 11 +++++++++--
src/main.c | 17 ++++++++---------
2 files changed, 17 insertions(+), 11 deletions(-)
New commits:
commit 061d6d7b840e0b26636f01ecfa94f07b3bfd40c4
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Jun 2 11:03:27 2011 -0500
sanlock: fix init restart
sanlock daemon creates and unlinks lockfile,
init.d/sanlock should not.
unlinking lockfile is the last thing sanlock
daemon should do.
init.d/sanlock restart should wait for stop
to finish (lockfile to be unlinked) before
doing start.
diff --git a/init.d/sanlock b/init.d/sanlock
index c05fa9c..d46dcef 100644
--- a/init.d/sanlock
+++ b/init.d/sanlock
@@ -33,7 +33,7 @@ start() {
daemon $prog daemon $SANLOCKOPTS
retval=$?
echo
- [ $retval -eq 0 ] && touch $lockfile
+ [ $retval -eq 0 ]
return $retval
}
@@ -42,11 +42,18 @@ stop() {
killproc -p $lockfile $prog -TERM
retval=$?
echo
- [ $retval -eq 0 ] && rm -f $lockfile
+ [ $retval -eq 0 ]
+}
+
+wait_for_stop() {
+ while [ -e $lockfile ]; do
+ sleep .5
+ done
}
restart() {
stop
+ wait_for_stop
start
}
diff --git a/src/main.c b/src/main.c
index 13b32a4..c12ac7b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2161,21 +2161,21 @@ static int do_daemon(void)
if (rv < 0)
return rv;
- setup_logging();
-
- setup_priority();
-
fd = lockfile(SANLK_RUN_DIR, SANLK_LOCKFILE_NAME);
if (fd < 0)
- goto out;
+ return fd;
+
+ setup_logging();
log_error("sanlock daemon started aio %d %d renew %d %d",
main_task.use_aio, main_task.io_timeout_seconds,
main_task.id_renewal_seconds, main_task.id_renewal_fail_seconds);
+ setup_priority();
+
rv = thread_pool_create(DEFAULT_MIN_WORKER_THREADS, com.max_worker_threads);
if (rv < 0)
- goto out_lockfile;
+ goto out_logging;
rv = setup_watchdog();
if (rv < 0)
@@ -2199,10 +2199,9 @@ static int do_daemon(void)
out_threads:
thread_pool_free();
- out_lockfile:
- unlink_lockfile(fd, SANLK_RUN_DIR, SANLK_LOCKFILE_NAME);
- out:
+ out_logging:
close_logging();
+ unlink_lockfile(fd, SANLK_RUN_DIR, SANLK_LOCKFILE_NAME);
return rv;
}