cluster: STABLE31 - qdiskd: Fix auto-vote calculation loop

Lon Hohberger lon at fedoraproject.org
Fri Feb 4 16:25:38 UTC 2011


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=cbf98a5623e7177d497092f7a7b0e170b8b3177e
Commit:        cbf98a5623e7177d497092f7a7b0e170b8b3177e
Parent:        e2c5e231eb9d6732235a073e2556993891b79e3f
Author:        Lon Hohberger <lhh at redhat.com>
AuthorDate:    Fri Feb 4 11:19:50 2011 -0500
Committer:     Lon Hohberger <lhh at redhat.com>
CommitterDate: Fri Feb 4 11:23:39 2011 -0500

qdiskd: Fix auto-vote calculation loop

Resolves: rhbz#663433

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 cman/qdisk/disk.c |    1 +
 cman/qdisk/main.c |   31 ++++++++++++++++---------------
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/cman/qdisk/disk.c b/cman/qdisk/disk.c
index 1f646ce..9884ea7 100644
--- a/cman/qdisk/disk.c
+++ b/cman/qdisk/disk.c
@@ -24,6 +24,7 @@
 #include <platform.h>
 #include <unistd.h>
 #include <time.h>
+#include <linux/types.h>
 #include <linux/fs.h>
 #include <liblogthread.h>
 #include <zlib.h>
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index ebdb018..9262af2 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -1377,32 +1377,33 @@ auto_qdisk_votes(int desc)
 {
 	int ret = 1;
 	char buf[PATH_MAX];
-	char *name;
+	char *v = NULL, *name = NULL;
 
 	while (1) {
 		int votes=0;
 
+		name = NULL;
+		snprintf(buf, sizeof(buf)-1,
+			"/cluster/clusternodes/clusternode[%d]/@name", ret);
+		if (ccs_get(desc, buf, &name) != 0)
+			break;
+
 		snprintf(buf, sizeof(buf)-1,
 			"/cluster/clusternodes/clusternode[%d]/@votes", ret);
 
-		name = NULL;
-		if (ccs_get(desc, buf, &name) == 0)
-			votes = atoi(name);
-		else
+		if (ccs_get(desc, buf, &v) == 0) {
+			votes = atoi(v);
+			free(v);
+			v = NULL;
+		} else {
 			votes = 1;
+		}
 
 		if (votes != 1) {
-			free(name);
 
-			snprintf(buf, sizeof(buf)-1,
-			    "/cluster/clusternodes/clusternode[%d]/@name",
-			    ret);
-
-			if (ccs_get(desc, buf, &name) == 0) {
-				logt_print(LOG_ERR, "%s's vote count is %d\n",
-					   name, votes);
-				free(name);
-			}
+			logt_print(LOG_ERR, "%s's vote count is %d\n",
+				   name, votes);
+			free(name);
 
 			logt_print(LOG_ERR, "Set all node vote counts to 1 "
 				   "or specify qdiskd's votes\n");


More information about the cluster-commits mailing list