[Sheepdog] [PATCH] sheep: exit when corosync stops running unexpectedly

Liu Yuan namei.unix at gmail.com
Mon Aug 29 08:36:49 CEST 2011


From: Liu Yuan <tailai.ly at taobao.com>

When the corosync dies, sheep will recive a signal but currently
ignores it. If corosync restarts, we have to manually kill sheep
and restart it to work with corosync. By simplicity, sheep should
exit when corosync dies. Other policy like handling corosync re-join
would be considered later.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/group.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/sheep/group.c b/sheep/group.c
index 92f079d..34f42bc 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -14,6 +14,7 @@
 #include <netdb.h>
 #include <arpa/inet.h>
 #include <sys/time.h>
+#include <sys/epoll.h>
 #include <corosync/cpg.h>
 #include <corosync/cfg.h>
 
@@ -343,6 +344,12 @@ forward:
 
 static void group_handler(int listen_fd, int events, void *data)
 {
+	if (events & EPOLLHUP) {
+		eprintf("Receive EPOLLHUP event. Is corosync stopped running?\n");
+		log_close();
+		exit(1);
+	}
+
 	cpg_dispatch(sys->handle, CPG_DISPATCH_ALL);
 }
 
-- 
1.7.5.1




More information about the sheepdog mailing list