[sheepdog] [PATCH] sheep: fix a crash caused by float point exception in recalculate_vnodes
levin li
levin108 at gmail.com
Sun Aug 5 17:55:54 CEST 2012
From: levin li <xingke.lwp at taobao.com>
When sheep starts as a gateway-only node firstly in the cluster, there's
no non-gateway-only nodes and thus nr_non_gateway_nodes is zero, and it
casues to divide zero which causes gateway-only node crash
Signed-off-by: levin li <xingke.lwp at taobao.com>
---
sheep/group.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sheep/group.c b/sheep/group.c
index 8ebb3e6..05ffb3e 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -797,6 +797,10 @@ void recalculate_vnodes(struct sd_node *nodes, int nr_nodes)
nr_non_gateway_nodes++;
}
}
+
+ if (!nr_non_gateway_nodes)
+ return;
+
avg_size /= nr_non_gateway_nodes;
for (i = 0; i < nr_nodes; i++) {
--
1.7.10
More information about the sheepdog
mailing list