[sheepdog] [PATCH v2] zk: actively remove itself after leave_cluster() is called

ChenZhe cz at de3eb.cn
Mon May 13 09:07:19 CEST 2013


actively remove itself from zookeeper than waitting for timeout.

Signed-off-by: ChenZhe <cz at de3eb.cn>
---
 sheep/cluster/zookeeper.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 25152b3..648bb7a 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -510,7 +510,12 @@ 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];
+	snprintf(path, sizeof(path), MEMBER_ZNODE"/%s",
+			node_to_str(&this_node.node));
+	add_event(EVENT_LEAVE, &this_node, NULL, 0);
+	zk_delete_node(path, -1);
+	return 0;
 }
 
 static int zk_notify(void *msg, size_t msg_len)
-- 
1.7.9





More information about the sheepdog mailing list