[sheepdog] [PATCH v2 1/2] zookeeper: zk_join() should return 0 on success and -1 on error
Kai Zhang
kyle at zelin.io
Fri Aug 9 04:41:34 CEST 2013
Signed-off-by: Kai Zhang <kyle at zelin.io>
---
sheep/cluster/zookeeper.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 6e632fc..1ace8b6 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -174,6 +174,15 @@ static struct zk_node this_node;
return __rc; \
} \
} while (0)
+#define RETURN_VALUE_IF_ERROR(stmt, value, fmt, ...) \
+ do { \
+ int __rc = stmt; \
+ if (__rc != ZOK) { \
+ sd_eprintf("failed, " fmt ", %s", \
+ ##__VA_ARGS__, zerror(__rc)); \
+ return value; \
+ } \
+ } while (0)
#define RETURN_VOID_IF_ERROR(stmt, fmt, ...) \
do { \
int __rc = stmt; \
@@ -801,9 +810,9 @@ static int zk_join(const struct sd_node *myself,
}
zk_compete_master();
- RETURN_IF_ERROR(add_join_event(opaque, opaque_len), "");
+ RETURN_VALUE_IF_ERROR(add_join_event(opaque, opaque_len), -1, "");
- return ZOK;
+ return 0;
}
static int zk_leave(void)
--
1.7.9.5
More information about the sheepdog
mailing list