src/host_id.c | 5 ++++-
src/token_manager.c | 28 ++++++++++++++++++++++++----
2 files changed, 28 insertions(+), 5 deletions(-)
New commits:
commit 3d14379e4aea8eef07cfd0ff7dee586a89ef4b9d
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Sep 13 14:40:34 2011 -0500
sanlock: SIGTERM and SIGKILL for REQ_KILL_PID
and add some comments about another req mode
diff --git a/src/host_id.c b/src/host_id.c
index 4d39d82..18ef28d 100644
--- a/src/host_id.c
+++ b/src/host_id.c
@@ -519,6 +519,7 @@ static void *lockspace_thread(void *arg_in)
/*
* pet the watchdog
+ * (don't update on thread_stop because it's probably unlinked)
*/
if (delta_result == SANLK_OK && !sp->thread_stop)
@@ -543,7 +544,9 @@ static void *lockspace_thread(void *arg_in)
}
}
- /* unlink called below to get it done ASAP */
+ /* watchdog unlink was done in main_loop when thread_stop was set, to
+ get it done as quickly as possible in case the wd is about to fire. */
+
close_watchdog_file(sp);
out:
if (delta_result == SANLK_OK)
diff --git a/src/token_manager.c b/src/token_manager.c
index 6568af3..33de66a 100644
--- a/src/token_manager.c
+++ b/src/token_manager.c
@@ -440,15 +440,35 @@ static void *resource_thread(void *arg GNUC_UNUSED)
continue;
}
+ /*
+ * TODO: add force_mode SANLK_REQ_KILL_PID_OR_RESET
+ * which would attempt to kill the pid like KILL_PID,
+ * but if the pid doesn't exit will block watchdog
+ * updates to reset the host.
+ * Here set r->block_wd_time = now + pid_exit_time,
+ * In renewal check for any r in resources with
+ * block_wd_time <= now, and if found will not
+ * update the watchdog. If the pid continues to
+ * not exit, the wd will fire and reset the machine.
+ * If the pid exits before pid_exit_time, no wd
+ * updates will be skipped.
+ */
+
if (req.force_mode == SANLK_REQ_KILL_PID) {
- /* look up r again to check it still exists and
- pid is same? */
+ /* look up r again? verify it exists and pid same */
- log_error("req_kill_pid %d %.48s:%.48s", pid,
+ log_debug("req force_mode %u pid %d %.48s:%.48s",
+ req.force_mode, pid,
tt->r.lockspace_name, tt->r.name);
+
+ /* TODO: share code with kill_pids() to gradually
+ * escalate from killscript, SIGTERM, SIGKILL */
+
+ kill(pid, SIGTERM);
+ sleep(1);
kill(pid, SIGKILL);
} else {
- log_error("req force_mode unknown %u", req.force_mode);
+ log_error("req force_mode %u unknown", req.force_mode);
}
}
}