Gitweb:
http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: d6aaa9cc1e5de3d472c6c9169cf980cf2c0bea34
Parent: 4d6b610339b27a30deac7d9e29dc4236824b58ad
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Mon Jun 28 16:28:06 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Jun 29 14:29:02 2010 -0400
rgmanager: Use sysrq-b to reboot
This resolves an issue where the reboot() syscall
does not complete in rebooting the system, delaying
recovery if the main rgmanager process dies.
Resolves: rhbz#609181
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/daemons/watchdog.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/daemons/watchdog.c b/rgmanager/src/daemons/watchdog.c
index 6efd655..dfecab1 100644
--- a/rgmanager/src/daemons/watchdog.c
+++ b/rgmanager/src/daemons/watchdog.c
@@ -4,6 +4,7 @@
#include <sys/reboot.h>
#include <stdlib.h>
#include <sys/mman.h>
+#include <fcntl.h>
#include <signals.h>
#include <logging.h>
@@ -39,6 +40,24 @@ redirect_signals(void)
}
+static int
+sysrq_reboot(void)
+{
+ int fd;
+
+ fd = open("/proc/sysrq-trigger", O_WRONLY|O_SYNC);
+ if (fd < 0)
+ return fd;
+
+ write(fd, "b\n", 2);
+ fsync(fd);
+ fdatasync(fd);
+ close(fd);
+
+ return 0;
+}
+
+
/**
return watchdog's pid, or 0 on failure
*/
@@ -80,6 +99,7 @@ watchdog_init(void)
#else
logt_print(LOG_CRIT, "Watchdog: Daemon died, rebooting...\n");
sync();
+ sysrq_reboot();
reboot(RB_AUTOBOOT);
#endif
exit(255);