[sheepdog] [PATCH 02/13] zookeeper: fix clientid when sesstion changes

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


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

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

diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index c01e8ed..a3a5933 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -543,16 +543,17 @@ static void watcher(zhandle_t *zh, int type, int state, const char *path,
 
 	dprintf("path:%s, type:%d\n", path, type);
 
-	if (type == -1) {
+	/* discard useless event */
+	if (type < 0 || type == ZOO_CHILD_EVENT)
+		return;
+
+	if (type == ZOO_SESSION_EVENT) {
 		cid = zoo_client_id(zh);
 		assert(cid != NULL);
+		this_node.clientid = *cid;
 		dprintf("session change, clientid:%"PRId64"\n", cid->client_id);
 	}
 
-	/* discard useless event */
-	if (type < 0 || type == ZOO_CHILD_EVENT)
-		return;
-
 	if (type == ZOO_CREATED_EVENT || type == ZOO_CHANGED_EVENT) {
 		ret = sscanf(path, MEMBER_ZNODE "/%s", str);
 		if (ret == 1) {
@@ -575,7 +576,6 @@ static void watcher(zhandle_t *zh, int type, int state, const char *path,
 		return;
 	}
 
-	dprintf("write event to efd:%d\n", efd);
 	eventfd_write(efd, value);
 }
 
-- 
1.7.9.5




More information about the sheepdog mailing list