[Sheepdog] [zookeeper][PATCH v2 09/11] Fix bug: zk_leave doesn't work
Yunkai Zhang
yunkai.me at gmail.com
Thu Apr 26 17:21:28 CEST 2012
From: Yunkai Zhang <qiushu.zyk at taobao.com>
Now we just need to delete znode in /sheepdog/member,
and zookeeper will notify LEAVE event to all other
sheeps automatically.
Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
---
sheep/cluster/zookeeper.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index a18f9a0..3ec64a8 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -765,7 +765,10 @@ static int zk_join(struct sd_node *myself,
static int zk_leave(void)
{
- return add_event(zhandle, EVENT_LEAVE, &this_node, NULL, 0, NULL);
+ char path[256];
+ sprintf(path, MEMBER_ZNODE "/%s", node_to_str(&this_node.node));
+ dprintf("try to delete member path:%s\n", path);
+ return zk_delete(zhandle, path, -1);
}
static int zk_notify(void *msg, size_t msg_len, void (*block_cb)(void *arg))
--
1.7.7.6
More information about the sheepdog
mailing list