[sheepdog] [PATCH] zookeeper: return the found path in zk_find_seq_node

MORITA Kazutaka morita.kazutaka at gmail.com
Fri Jun 7 05:33:42 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

This is necessary for the zookeeper driver to get the queue position
on the first push.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/cluster/zookeeper.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 2be3e4b..45db10a 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -261,16 +261,14 @@ static bool zk_queue_peek(void)
 }
 
 /* return true if there is a node with 'id' in the queue. */
-static bool zk_find_seq_node(uint64_t id)
+static bool zk_find_seq_node(uint64_t id, char *seq_path, int seq_path_len)
 {
 	int rc, len;
 
 	for (int seq = queue_pos; ; seq++) {
-		char seq_path[MAX_NODE_STR_LEN];
 		struct zk_event ev;
 
-		snprintf(seq_path, sizeof(seq_path), QUEUE_ZNODE"/%010"PRId32,
-			 seq);
+		snprintf(seq_path, seq_path_len, QUEUE_ZNODE"/%010"PRId32, seq);
 		len = offsetof(typeof(ev), id) + sizeof(ev.id);
 		rc = zk_get_data(seq_path, &ev, &len);
 		switch (rc) {
@@ -307,7 +305,7 @@ again:
 		break;
 	case ZOPERATIONTIMEOUT:
 	case ZCONNECTIONLOSS:
-		if (!zk_find_seq_node(ev->id))
+		if (!zk_find_seq_node(ev->id, buf, sizeof(buf)))
 			/* retry if seq_node was not created */
 			goto again;
 		break;
-- 
1.7.9.5




More information about the sheepdog mailing list