[sheepdog] [PATCH v3] zookeeper: fix bug for default cluster id

Yu Yang yuyanggg at gmail.com
Wed Mar 4 08:04:03 CET 2015


From: Yu Yang <yuyang at cmss.chinamobile.com>

Append DEFAULT_BASE to hosts when cluster id is not set.

Signed-off-by: Yu Yang <yuyang at cmss.chinamobile.com>
---
 sheep/cluster/zookeeper.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 4f85043..a260363 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -1466,7 +1466,13 @@ static int zk_init(const char *option)
 
 	sd_info("version %d.%d.%d, address %s, timeout %d", ZOO_MAJOR_VERSION,
 		ZOO_MINOR_VERSION, ZOO_PATCH_VERSION, hosts, zk_timeout);
-	if (zk_connect(hosts, zk_watcher, zk_timeout) < 0)
+	if (!strchr(hosts, '/')) {
+		char buf[MAX_NODE_STR_LEN];
+		pstrcpy(buf, sizeof(buf), hosts);
+		strcat(buf, DEFAULT_BASE);
+		if (zk_connect(buf, zk_watcher, zk_timeout) < 0)
+			return -1;
+	} else if (zk_connect(hosts, zk_watcher, zk_timeout) < 0)
 		return -1;
 
 	timeo = zoo_recv_timeout(zhandle);
-- 
1.7.9.5




More information about the sheepdog mailing list