[sheepdog] [PATCH 2/3] zookeeper: use panic instead of assert for error handling

MORITA Kazutaka morita.kazutaka at gmail.com
Wed May 29 12:37:48 CEST 2013


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

Otherwise, the error check are not compiled when we define NDEBUG.

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

diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index c23291b..1013d60 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -353,12 +353,14 @@ static void push_join_response(struct zk_event *ev)
 
 static void zk_queue_pop_advance(struct zk_event *ev)
 {
-	int len;
+	int rc, len;
 	char path[MAX_NODE_STR_LEN];
 
 	len = sizeof(*ev);
 	snprintf(path, sizeof(path), QUEUE_ZNODE "/%010"PRId32, queue_pos);
-	assert(zk_get_data(path, ev, &len) == ZOK);
+	rc = zk_get_data(path, ev, &len);
+	if (rc != ZOK)
+		panic("failed to get data from %s, %s", path, zerror(rc));
 	sd_dprintf("%s, type:%d, len:%d, pos:%"PRId32, path, ev->type, len,
 		   queue_pos);
 	queue_pos++;
-- 
1.7.9.5




More information about the sheepdog mailing list