If we not rewatch znode in /sheepdog/member after it changed, we will lose all events of it in the future, such as DELETE event. Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com> --- sheep/cluster/zookeeper.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c index 49a8ade..fedb5a9 100644 --- a/sheep/cluster/zookeeper.c +++ b/sheep/cluster/zookeeper.c @@ -581,7 +581,7 @@ static void watcher(zhandle_t *zh, int type, int state, const char *path, void* eventfd_t value = 1; const clientid_t *cid; char str[256], *p; - int ret, i; + int ret, rc, i; dprintf("path:%s, type:%d\n", path, type); @@ -595,6 +595,14 @@ static void watcher(zhandle_t *zh, int type, int state, const char *path, void* if (type < 0 || type == ZOO_CHILD_EVENT) return; + if (type == ZOO_CHANGED_EVENT) { + ret = sscanf(path, MEMBER_ZNODE "/%s", str); + if (ret == 1) { + rc = zk_exists(zh, path, 1, NULL); + dprintf("watch path:%s, exists:%d\n", path, (rc==ZOK)); + } + } + if (type == ZOO_DELETED_EVENT) { ret = sscanf(path, MEMBER_ZNODE "/%s", str); if (ret != 1) { -- 1.7.7.6 |