Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=9e5... Commit: 9e5a1dafc93894612bc6436ac867c333b97c6181 Parent: d76d382f7452d8a6c6e2585d7f4bfe4f446c115c Author: Lon Hohberger lhh@redhat.com AuthorDate: Mon Jun 28 16:28:06 2010 -0400 Committer: Lon Hohberger lhh@redhat.com CommitterDate: Tue Jun 29 14:27:41 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@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);