<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2014/1/19 Liu Yuan <span dir="ltr"><<a href="mailto:namei.unix@gmail.com" target="_blank">namei.unix@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Sun, Jan 19, 2014 at 08:52:59PM +0800, Robin Dong wrote:<br>
> From: Robin Dong <<a href="mailto:sanbai@taobao.com">sanbai@taobao.com</a>><br>
><br>
> When a sheep daemon call zk_unlock(), it will remove the whole znode of 'lock-id' and<br>
> make zoo_create() fail in zk_lock() which called by another sheep daemon.<br>
> To avoid this, we should try to create a znode of 'lock-id' if zoo_create() fail.<br>
><br>
> Signed-off-by: Robin Dong <<a href="mailto:sanbai@taobao.com">sanbai@taobao.com</a>><br>
> ---<br>
> sheep/cluster/zookeeper.c | 4 ++++<br>
> 1 file changed, 4 insertions(+)<br>
><br>
> diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c<br>
> index ad5a9af..4527db1 100644<br>
> --- a/sheep/cluster/zookeeper.c<br>
> +++ b/sheep/cluster/zookeeper.c<br>
> @@ -1256,6 +1256,10 @@ static void zk_lock(uint64_t lock_id)<br>
> flags, my_path, MAX_NODE_STR_LEN);<br>
> if (rc == ZOK)<br>
> break;<br>
> + if (rc == ZNONODE) {<br>
> + zk_init_node(parent);<br>
<br>
</div>Should check error of zk_init_node and handle it.<br></blockquote><div><br></div><div>No matter whatever error the zk_init_node() return, we only have to "continue" in zk_lock() </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks<br>
<span class="HOEnZb"><font color="#888888">Yuan<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>--<br>Best Regard<br>Robin Dong
</div></div>