[sheepdog] [PATCH 08/13] zookeeper: refactor zk_member_init()

Liu Yuan namei.unix at gmail.com
Tue Dec 18 06:37:57 CET 2012


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

- remove static finished

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/cluster/zookeeper.c |   33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 3c482a4..c3fd3e8 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -453,32 +453,27 @@ static void zk_queue_init(void)
 
 static void zk_member_init(void)
 {
-	static bool finished;
 	int rc, len;
 	struct String_vector strs;
 	struct zk_node znode;
 	char path[256];
 
-	if (finished)
+	if (zk_member_empty())
 		return;
 
-	finished = true;
-
-	if (!zk_member_empty()) {
-		FOR_EACH_ZNODE(MEMBER_ZNODE, path, &strs) {
-			len = sizeof(znode);
-			rc = zk_get_data(path, 1, (char *)&znode, &len, NULL);
-			if (rc != ZOK)
-				continue;
-
-			switch (rc) {
-			case ZOK:
-				zk_tree_add(&znode);
-			case ZNONODE:
-				break;
-			default:
-				panic("failed to zk_get_data path:%s, rc:%d\n", path, rc);
-			}
+	FOR_EACH_ZNODE(MEMBER_ZNODE, path, &strs) {
+		len = sizeof(znode);
+		rc = zk_get_data(path, 1, (char *)&znode, &len, NULL);
+		if (rc != ZOK)
+			continue;
+
+		switch (rc) {
+		case ZOK:
+			zk_tree_add(&znode);
+		case ZNONODE:
+			break;
+		default:
+			panic("zk_get_data failed:%s, rc:%d\n", path, rc);
 		}
 	}
 }
-- 
1.7.9.5




More information about the sheepdog mailing list