[sheepdog] [PATCH] sheep: when a sheep node leaved, its node in zk was not removed immediately

Liu Yuan namei.unix at gmail.com
Mon May 13 08:53:18 CEST 2013


On 05/13/2013 02:42 PM, ChenZhe wrote:
> 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;
	
No, simply return 0 and no need to check add_event and zk_delete_node.

>  }
>  
>  static int zk_notify(void *msg, size_t msg_len)
> 

Please brief the subject and correct the prefix, I'd suggest:

zk: actively remove itself after leave_cluster() is called

Thanks,
Yuan



More information about the sheepdog mailing list