[Sheepdog] [zookeeper][PATCH v2 07/11] If previous zookeeper session exists, shutdown sheep

Yunkai Zhang yunkai.me at gmail.com
Thu Apr 26 17:21:26 CEST 2012


From: Yunkai Zhang <qiushu.zyk at taobao.com>


Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
---
 sheep/cluster/zookeeper.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index e391bd1..d90e27f 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -723,6 +723,7 @@ static int zk_join(struct sd_node *myself,
 {
 	int rc;
 	char path[256];
+	struct zk_node *znode;
 	const clientid_t *cid;
 
 	zk_lock(zhandle);
@@ -730,6 +731,11 @@ static int zk_join(struct sd_node *myself,
 	zk_data_init(zhandle);
 
 	this_node.node = *myself;
+
+	znode = find_node(zk_nodes, nr_zk_nodes, &this_node);
+	if (znode)
+		panic("previous zookeeper session exist, shutdown\n");
+
 	this_node.seq = zk_queue_seq(zhandle);
 	this_node.joined = 0;
 
-- 
1.7.7.6




More information about the sheepdog mailing list