[sheepdog] [PATCH] sheep: when a sheep node leaved, its node in zk was not removed immediately
ChenZhe
cz at de3eb.cn
Mon May 13 08:42:57 CEST 2013
when a node is leaving, initiative to remove itself from zookeeper than
waitting for timeout.
Signed-off-by: ChenZhe <cz at de3eb.cn>
---
sheep/cluster/zookeeper.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 25152b3..77b99ed 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -510,7 +510,13 @@ static int zk_join(const struct sd_node *myself,
static int zk_leave(void)
{
- return add_event(EVENT_LEAVE, &this_node, NULL, 0);
+ char path[PATH_MAX];
+ int ret;
+ snprintf(path, sizeof(path), MEMBER_ZNODE"/%s",
+ node_to_str(&this_node.node));
+ ret = add_event(EVENT_LEAVE, &this_node, NULL, 0);
+ ret |= zk_delete_node(path, -1);
+ return ret;
}
static int zk_notify(void *msg, size_t msg_len)
--
1.7.9
More information about the sheepdog
mailing list