[Sheepdog] [zookeeper][PATCH 5/5] Fix bug: discard useless zookeeper event
Yunkai Zhang
yunkai.me at gmail.com
Tue Mar 6 19:10:36 CET 2012
We just care about child event of /sheepdog/queue/*
Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
---
sheep/cluster/zookeeper.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 6f53ac4..21b15d2 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -360,10 +360,16 @@ static void watcher(zhandle_t *zh, int type, int state, const char *path, void*
size_t nr_nodes;
struct sd_node nodes[SD_MAX_NODES];
+ dprintf("path:%s, type:%d\n", path, type);
+
+ /* discard useless event */
+ if (type == ZOO_CHILD_EVENT)
+ return;
+
if (type == ZOO_DELETED_EVENT) {
ret = sscanf(path, MEMBER_ZNODE "/%[^\n]", str);
if (ret != 1)
- goto out;
+ return;
/* check the failed node */
nr_nodes = get_nodes(zh, nodes);
@@ -371,11 +377,12 @@ static void watcher(zhandle_t *zh, int type, int state, const char *path, void*
if (strcmp(str, node_to_str(nodes + i)) == 0) {
add_event(zh, EVENT_LEAVE, nodes + i, NULL, 0,
NULL);
- goto out;
+ return;
}
}
}
-out:
+
+ dprintf("write event to efd:%d\n", efd);
eventfd_write(efd, value);
}
--
1.7.7.6
More information about the sheepdog
mailing list