? make/defines.mk
Index: cman/daemon/cmanccs.c
===================================================================
RCS file: /cvs/cluster/cluster/cman/daemon/cmanccs.c,v
retrieving revision 1.36
diff -u -r1.36 cmanccs.c
--- cman/daemon/cmanccs.c	24 Oct 2007 05:58:07 -0000	1.36
+++ cman/daemon/cmanccs.c	24 Oct 2007 06:35:34 -0000
@@ -47,6 +47,7 @@
 
 #define NODE_NAME_PATH_BYNAME	"/cluster/clusternodes/clusternode[@name=\"%s\"]/@name"
 #define NODE_NAME_PATH_BYNUM	"/cluster/clusternodes/clusternode[%d]/@name"
+#define NODE_SPECTATOR_PATH	"/cluster/clusternodes/clusternode[@name=\"%s\"]/spectator"
 #define NODE_VOTES_PATH		"/cluster/clusternodes/clusternode[@name=\"%s\"]/@votes"
 #define NODE_NODEID_PATH	"/cluster/clusternodes/clusternode[@name=\"%s\"]/@nodeid"
 #define NODE_ALTNAMES_PATH	"/cluster/clusternodes/clusternode[@name=\"%s\"]/altname[%d]/@name"
@@ -150,8 +151,20 @@
 		if (!ccs_get(ctree, path, &str)) {
 			votes = atoi(str);
 			free(str);
-		} else
-			votes = 1;
+		} else {
+			ret = snprintf(path, sizeof(path), NODE_SPECTATOR_PATH, nodename);
+			if (ret < 0 || ret >= sizeof(path)) {
+				error = -E2BIG;
+				goto out_err;
+			}
+			if (!ccs_get(ctree, path, &str)) {
+				votes = 0; /* we are a spectator */
+				if (str)
+					free(str);
+			} else {
+				votes = 1;
+			}
+		}
 
 		ret = snprintf(path, sizeof(path), NODE_NODEID_PATH, nodename);
 		if (ret < 0 || (size_t) ret >= sizeof(path)) {
@@ -585,17 +598,27 @@
 			node_count++;
 
 			ret = snprintf(path, sizeof(path), NODE_VOTES_PATH, name);
-			free(name);
-
 			if (ret < 0 || (size_t) ret >= sizeof(path)) {
+				free(name);
 				error = -E2BIG;
 				break;
 			}
 
 			error = ccs_get(cd, path, &str);
-			if (error)
-				vote_sum++;
-			else {
+			if (error) {
+				ret = snprintf(path, sizeof(path), NODE_SPECTATOR_PATH, name);
+				if (ret < 0 || (size_t) ret >= sizeof(path)) {
+					free(name);
+					error = -E2BIG;
+					break;
+				}
+				if (!ccs_get(cd, path, &str)) {
+					if (str)
+						free(str); /* we are a spectator. don't increase the vote_sum */
+				} else {
+					vote_sum++;
+				}
+			} else {
 				if (atoi(str) < 0) {
 					log_printf(LOG_ERR, "negative votes not allowed");
 					write_cman_pipe("Found negative votes for this node in CCS");
@@ -605,6 +628,7 @@
 				vote_sum += atoi(str);
 				free(str);
 			}
+			free(name);
 		}
 
 		/* optional expected_votes supercedes vote sum */
@@ -671,9 +695,20 @@
 				return -EINVAL;
 			}
 			votes = votestmp;
-		}
-		else {
-			votes = 1;
+		} else {
+			ret = snprintf(path, sizeof(path), NODE_SPECTATOR_PATH, nodename);
+			if (ret < 0 || (size_t) ret >= sizeof(path)) {
+				log_printf(LOG_ERR, "unable to find spectator info for %s", nodename);
+				write_cman_pipe("Unable to find spectator info");
+				return -E2BIG;
+			}
+			if (!ccs_get(cd, path, &str)) {
+				votes = 0; /* we are a spectator */
+				if (str)
+					free(str);
+			} else {
+				votes = 1;
+			}
 		}
 	}
 
